algorithm2e - override defaults












6















I'm using using algorithm2e package with the following settings:



usepackage[ruled,vlined,linesnumbered,noresetcount]{algorithm2e}


But for some subset of algorithms in the same document, I want to use this setting:



usepackage[boxed]{algorithm2e}


Is there a way to override the default setting just for a subset?



I found a similar question:
algorithm2e with 'ruled' but with caption underneath?
Here newenvironment is used to override the default setting of an option. But I want to override the option itself.



I wish there was a way to load a package several times with different options for each instance.










share|improve this question

























  • So the boxed algorithm should not have vlined, nor linesnumbered, nor noresetcount?

    – Werner
    Nov 23 '15 at 21:40











  • yes. I was reading the documentation on algorithm2e. RestyleAlgo{boxed} overrides ruled, but doesn't seem to override other things.

    – arunmoezhi
    Nov 23 '15 at 21:43
















6















I'm using using algorithm2e package with the following settings:



usepackage[ruled,vlined,linesnumbered,noresetcount]{algorithm2e}


But for some subset of algorithms in the same document, I want to use this setting:



usepackage[boxed]{algorithm2e}


Is there a way to override the default setting just for a subset?



I found a similar question:
algorithm2e with 'ruled' but with caption underneath?
Here newenvironment is used to override the default setting of an option. But I want to override the option itself.



I wish there was a way to load a package several times with different options for each instance.










share|improve this question

























  • So the boxed algorithm should not have vlined, nor linesnumbered, nor noresetcount?

    – Werner
    Nov 23 '15 at 21:40











  • yes. I was reading the documentation on algorithm2e. RestyleAlgo{boxed} overrides ruled, but doesn't seem to override other things.

    – arunmoezhi
    Nov 23 '15 at 21:43














6












6








6


3






I'm using using algorithm2e package with the following settings:



usepackage[ruled,vlined,linesnumbered,noresetcount]{algorithm2e}


But for some subset of algorithms in the same document, I want to use this setting:



usepackage[boxed]{algorithm2e}


Is there a way to override the default setting just for a subset?



I found a similar question:
algorithm2e with 'ruled' but with caption underneath?
Here newenvironment is used to override the default setting of an option. But I want to override the option itself.



I wish there was a way to load a package several times with different options for each instance.










share|improve this question
















I'm using using algorithm2e package with the following settings:



usepackage[ruled,vlined,linesnumbered,noresetcount]{algorithm2e}


But for some subset of algorithms in the same document, I want to use this setting:



usepackage[boxed]{algorithm2e}


Is there a way to override the default setting just for a subset?



I found a similar question:
algorithm2e with 'ruled' but with caption underneath?
Here newenvironment is used to override the default setting of an option. But I want to override the option itself.



I wish there was a way to load a package several times with different options for each instance.







algorithm2e package-options






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 13 '17 at 12:35









Community

1




1










asked Nov 23 '15 at 21:19









arunmoezhiarunmoezhi

5502820




5502820













  • So the boxed algorithm should not have vlined, nor linesnumbered, nor noresetcount?

    – Werner
    Nov 23 '15 at 21:40











  • yes. I was reading the documentation on algorithm2e. RestyleAlgo{boxed} overrides ruled, but doesn't seem to override other things.

    – arunmoezhi
    Nov 23 '15 at 21:43



















  • So the boxed algorithm should not have vlined, nor linesnumbered, nor noresetcount?

    – Werner
    Nov 23 '15 at 21:40











  • yes. I was reading the documentation on algorithm2e. RestyleAlgo{boxed} overrides ruled, but doesn't seem to override other things.

    – arunmoezhi
    Nov 23 '15 at 21:43

















So the boxed algorithm should not have vlined, nor linesnumbered, nor noresetcount?

– Werner
Nov 23 '15 at 21:40





So the boxed algorithm should not have vlined, nor linesnumbered, nor noresetcount?

– Werner
Nov 23 '15 at 21:40













yes. I was reading the documentation on algorithm2e. RestyleAlgo{boxed} overrides ruled, but doesn't seem to override other things.

– arunmoezhi
Nov 23 '15 at 21:43





yes. I was reading the documentation on algorithm2e. RestyleAlgo{boxed} overrides ruled, but doesn't seem to override other things.

– arunmoezhi
Nov 23 '15 at 21:43










2 Answers
2






active

oldest

votes


















6














You have to adjust the settings manually:



enter image description here



documentclass{article}

usepackage[ruled,vlined,linesnumbered,noresetcount]{algorithm2e}

makeatletter
newcommand{AlgoResetCount}{renewcommand{@ResetCounterIfNeeded}{setcounter{AlgoLine}{0}}}
newcommand{AlgoNoResetCount}{renewcommand{@ResetCounterIfNeeded}{}}
newcounter{AlgoSavedLineCount}
newcommand{AlgoSaveLineCount}{setcounter{AlgoSavedLineCount}{value{AlgoLine}}}
newcommand{AlgoRestoreLineCount}{setcounter{AlgoLine}{value{AlgoSavedLineCount}}}
makeatother

begin{document}

begin{algorithm}[H]
KwData{this text}
KwResult{how to write algorithm with LaTeX2e }
initialization;
While{not at end of this document}{
read current;
eIf{understand}{
go to next section;
current section becomes this one;
}{
go back to the beginning of current section;
}
}
caption{How to write algorithms}
end{algorithm}

RestyleAlgo{boxed}% Change from the 'ruled' style to 'boxed'
SetAlgoNoLine% Removes 'vlined' option (somewhat opposite of SetAlgoVlined)
LinesNumberedHidden% Removes 'linesnumbered' option (opposite of LinesNumbered)
AlgoSaveLineCount% Stores the algorithm line number (similar to 'resetcount' in the package load option)

begin{algorithm}[H]
KwData{this text}
KwResult{how to write algorithm with LaTeX2e }
initialization;
While{not at end of this document}{
read current;
eIf{understand}{
go to next section;
current section becomes this one;
}{
go back to the beginning of current section;
}
}
caption{How to write algorithms}
end{algorithm}

RestyleAlgo{ruled}% Change from the 'boxed' style to 'ruled'
SetAlgoVlined% Similar to 'vlined' in the package load option
LinesNumbered% Similar to 'linesnumbered' in the package load option
AlgoRestoreLineCount% Restores the algorithm line number (similar to 'noresetcount' in the package load option)

begin{algorithm}[H]
KwData{this text}
KwResult{how to write algorithm with LaTeX2e }
initialization;
While{not at end of this document}{
read current;
eIf{understand}{
go to next section;
current section becomes this one;
}{
go back to the beginning of current section;
}
}
caption{How to write algorithms}
end{algorithm}

end{document}





share|improve this answer
























  • What would I have to do to remove the option "figure" for a certain algo: usepackage[figure]{algorithm2e} Is that also possible? ("figure" lets the algo behave like a figure.)

    – lukas.coenig
    Jul 19 '16 at 16:18













  • ...or the other way around - include this option for certain algos, but not as a global option.

    – lukas.coenig
    Jul 19 '16 at 16:20



















2














Not much manual adjustment is needed! You only add
RestyleAlgo{options}
right before the algorithm definition you want to be overridden.



Note that options can be one of the followings: boxed, boxruled, ruled and algoruled.



Ex:



After defining usepachage{algorithm2e} in preamble:



     RestyleAlgo{ruled}
begin{algorithm}
....
end{algorithm}


That's it!






share|improve this answer


























  • Welcome to TeX.SE!

    – Kurt
    Mar 17 at 12:41











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f279655%2falgorithm2e-override-defaults%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









6














You have to adjust the settings manually:



enter image description here



documentclass{article}

usepackage[ruled,vlined,linesnumbered,noresetcount]{algorithm2e}

makeatletter
newcommand{AlgoResetCount}{renewcommand{@ResetCounterIfNeeded}{setcounter{AlgoLine}{0}}}
newcommand{AlgoNoResetCount}{renewcommand{@ResetCounterIfNeeded}{}}
newcounter{AlgoSavedLineCount}
newcommand{AlgoSaveLineCount}{setcounter{AlgoSavedLineCount}{value{AlgoLine}}}
newcommand{AlgoRestoreLineCount}{setcounter{AlgoLine}{value{AlgoSavedLineCount}}}
makeatother

begin{document}

begin{algorithm}[H]
KwData{this text}
KwResult{how to write algorithm with LaTeX2e }
initialization;
While{not at end of this document}{
read current;
eIf{understand}{
go to next section;
current section becomes this one;
}{
go back to the beginning of current section;
}
}
caption{How to write algorithms}
end{algorithm}

RestyleAlgo{boxed}% Change from the 'ruled' style to 'boxed'
SetAlgoNoLine% Removes 'vlined' option (somewhat opposite of SetAlgoVlined)
LinesNumberedHidden% Removes 'linesnumbered' option (opposite of LinesNumbered)
AlgoSaveLineCount% Stores the algorithm line number (similar to 'resetcount' in the package load option)

begin{algorithm}[H]
KwData{this text}
KwResult{how to write algorithm with LaTeX2e }
initialization;
While{not at end of this document}{
read current;
eIf{understand}{
go to next section;
current section becomes this one;
}{
go back to the beginning of current section;
}
}
caption{How to write algorithms}
end{algorithm}

RestyleAlgo{ruled}% Change from the 'boxed' style to 'ruled'
SetAlgoVlined% Similar to 'vlined' in the package load option
LinesNumbered% Similar to 'linesnumbered' in the package load option
AlgoRestoreLineCount% Restores the algorithm line number (similar to 'noresetcount' in the package load option)

begin{algorithm}[H]
KwData{this text}
KwResult{how to write algorithm with LaTeX2e }
initialization;
While{not at end of this document}{
read current;
eIf{understand}{
go to next section;
current section becomes this one;
}{
go back to the beginning of current section;
}
}
caption{How to write algorithms}
end{algorithm}

end{document}





share|improve this answer
























  • What would I have to do to remove the option "figure" for a certain algo: usepackage[figure]{algorithm2e} Is that also possible? ("figure" lets the algo behave like a figure.)

    – lukas.coenig
    Jul 19 '16 at 16:18













  • ...or the other way around - include this option for certain algos, but not as a global option.

    – lukas.coenig
    Jul 19 '16 at 16:20
















6














You have to adjust the settings manually:



enter image description here



documentclass{article}

usepackage[ruled,vlined,linesnumbered,noresetcount]{algorithm2e}

makeatletter
newcommand{AlgoResetCount}{renewcommand{@ResetCounterIfNeeded}{setcounter{AlgoLine}{0}}}
newcommand{AlgoNoResetCount}{renewcommand{@ResetCounterIfNeeded}{}}
newcounter{AlgoSavedLineCount}
newcommand{AlgoSaveLineCount}{setcounter{AlgoSavedLineCount}{value{AlgoLine}}}
newcommand{AlgoRestoreLineCount}{setcounter{AlgoLine}{value{AlgoSavedLineCount}}}
makeatother

begin{document}

begin{algorithm}[H]
KwData{this text}
KwResult{how to write algorithm with LaTeX2e }
initialization;
While{not at end of this document}{
read current;
eIf{understand}{
go to next section;
current section becomes this one;
}{
go back to the beginning of current section;
}
}
caption{How to write algorithms}
end{algorithm}

RestyleAlgo{boxed}% Change from the 'ruled' style to 'boxed'
SetAlgoNoLine% Removes 'vlined' option (somewhat opposite of SetAlgoVlined)
LinesNumberedHidden% Removes 'linesnumbered' option (opposite of LinesNumbered)
AlgoSaveLineCount% Stores the algorithm line number (similar to 'resetcount' in the package load option)

begin{algorithm}[H]
KwData{this text}
KwResult{how to write algorithm with LaTeX2e }
initialization;
While{not at end of this document}{
read current;
eIf{understand}{
go to next section;
current section becomes this one;
}{
go back to the beginning of current section;
}
}
caption{How to write algorithms}
end{algorithm}

RestyleAlgo{ruled}% Change from the 'boxed' style to 'ruled'
SetAlgoVlined% Similar to 'vlined' in the package load option
LinesNumbered% Similar to 'linesnumbered' in the package load option
AlgoRestoreLineCount% Restores the algorithm line number (similar to 'noresetcount' in the package load option)

begin{algorithm}[H]
KwData{this text}
KwResult{how to write algorithm with LaTeX2e }
initialization;
While{not at end of this document}{
read current;
eIf{understand}{
go to next section;
current section becomes this one;
}{
go back to the beginning of current section;
}
}
caption{How to write algorithms}
end{algorithm}

end{document}





share|improve this answer
























  • What would I have to do to remove the option "figure" for a certain algo: usepackage[figure]{algorithm2e} Is that also possible? ("figure" lets the algo behave like a figure.)

    – lukas.coenig
    Jul 19 '16 at 16:18













  • ...or the other way around - include this option for certain algos, but not as a global option.

    – lukas.coenig
    Jul 19 '16 at 16:20














6












6








6







You have to adjust the settings manually:



enter image description here



documentclass{article}

usepackage[ruled,vlined,linesnumbered,noresetcount]{algorithm2e}

makeatletter
newcommand{AlgoResetCount}{renewcommand{@ResetCounterIfNeeded}{setcounter{AlgoLine}{0}}}
newcommand{AlgoNoResetCount}{renewcommand{@ResetCounterIfNeeded}{}}
newcounter{AlgoSavedLineCount}
newcommand{AlgoSaveLineCount}{setcounter{AlgoSavedLineCount}{value{AlgoLine}}}
newcommand{AlgoRestoreLineCount}{setcounter{AlgoLine}{value{AlgoSavedLineCount}}}
makeatother

begin{document}

begin{algorithm}[H]
KwData{this text}
KwResult{how to write algorithm with LaTeX2e }
initialization;
While{not at end of this document}{
read current;
eIf{understand}{
go to next section;
current section becomes this one;
}{
go back to the beginning of current section;
}
}
caption{How to write algorithms}
end{algorithm}

RestyleAlgo{boxed}% Change from the 'ruled' style to 'boxed'
SetAlgoNoLine% Removes 'vlined' option (somewhat opposite of SetAlgoVlined)
LinesNumberedHidden% Removes 'linesnumbered' option (opposite of LinesNumbered)
AlgoSaveLineCount% Stores the algorithm line number (similar to 'resetcount' in the package load option)

begin{algorithm}[H]
KwData{this text}
KwResult{how to write algorithm with LaTeX2e }
initialization;
While{not at end of this document}{
read current;
eIf{understand}{
go to next section;
current section becomes this one;
}{
go back to the beginning of current section;
}
}
caption{How to write algorithms}
end{algorithm}

RestyleAlgo{ruled}% Change from the 'boxed' style to 'ruled'
SetAlgoVlined% Similar to 'vlined' in the package load option
LinesNumbered% Similar to 'linesnumbered' in the package load option
AlgoRestoreLineCount% Restores the algorithm line number (similar to 'noresetcount' in the package load option)

begin{algorithm}[H]
KwData{this text}
KwResult{how to write algorithm with LaTeX2e }
initialization;
While{not at end of this document}{
read current;
eIf{understand}{
go to next section;
current section becomes this one;
}{
go back to the beginning of current section;
}
}
caption{How to write algorithms}
end{algorithm}

end{document}





share|improve this answer













You have to adjust the settings manually:



enter image description here



documentclass{article}

usepackage[ruled,vlined,linesnumbered,noresetcount]{algorithm2e}

makeatletter
newcommand{AlgoResetCount}{renewcommand{@ResetCounterIfNeeded}{setcounter{AlgoLine}{0}}}
newcommand{AlgoNoResetCount}{renewcommand{@ResetCounterIfNeeded}{}}
newcounter{AlgoSavedLineCount}
newcommand{AlgoSaveLineCount}{setcounter{AlgoSavedLineCount}{value{AlgoLine}}}
newcommand{AlgoRestoreLineCount}{setcounter{AlgoLine}{value{AlgoSavedLineCount}}}
makeatother

begin{document}

begin{algorithm}[H]
KwData{this text}
KwResult{how to write algorithm with LaTeX2e }
initialization;
While{not at end of this document}{
read current;
eIf{understand}{
go to next section;
current section becomes this one;
}{
go back to the beginning of current section;
}
}
caption{How to write algorithms}
end{algorithm}

RestyleAlgo{boxed}% Change from the 'ruled' style to 'boxed'
SetAlgoNoLine% Removes 'vlined' option (somewhat opposite of SetAlgoVlined)
LinesNumberedHidden% Removes 'linesnumbered' option (opposite of LinesNumbered)
AlgoSaveLineCount% Stores the algorithm line number (similar to 'resetcount' in the package load option)

begin{algorithm}[H]
KwData{this text}
KwResult{how to write algorithm with LaTeX2e }
initialization;
While{not at end of this document}{
read current;
eIf{understand}{
go to next section;
current section becomes this one;
}{
go back to the beginning of current section;
}
}
caption{How to write algorithms}
end{algorithm}

RestyleAlgo{ruled}% Change from the 'boxed' style to 'ruled'
SetAlgoVlined% Similar to 'vlined' in the package load option
LinesNumbered% Similar to 'linesnumbered' in the package load option
AlgoRestoreLineCount% Restores the algorithm line number (similar to 'noresetcount' in the package load option)

begin{algorithm}[H]
KwData{this text}
KwResult{how to write algorithm with LaTeX2e }
initialization;
While{not at end of this document}{
read current;
eIf{understand}{
go to next section;
current section becomes this one;
}{
go back to the beginning of current section;
}
}
caption{How to write algorithms}
end{algorithm}

end{document}






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 23 '15 at 22:27









WernerWerner

449k719941699




449k719941699













  • What would I have to do to remove the option "figure" for a certain algo: usepackage[figure]{algorithm2e} Is that also possible? ("figure" lets the algo behave like a figure.)

    – lukas.coenig
    Jul 19 '16 at 16:18













  • ...or the other way around - include this option for certain algos, but not as a global option.

    – lukas.coenig
    Jul 19 '16 at 16:20



















  • What would I have to do to remove the option "figure" for a certain algo: usepackage[figure]{algorithm2e} Is that also possible? ("figure" lets the algo behave like a figure.)

    – lukas.coenig
    Jul 19 '16 at 16:18













  • ...or the other way around - include this option for certain algos, but not as a global option.

    – lukas.coenig
    Jul 19 '16 at 16:20

















What would I have to do to remove the option "figure" for a certain algo: usepackage[figure]{algorithm2e} Is that also possible? ("figure" lets the algo behave like a figure.)

– lukas.coenig
Jul 19 '16 at 16:18







What would I have to do to remove the option "figure" for a certain algo: usepackage[figure]{algorithm2e} Is that also possible? ("figure" lets the algo behave like a figure.)

– lukas.coenig
Jul 19 '16 at 16:18















...or the other way around - include this option for certain algos, but not as a global option.

– lukas.coenig
Jul 19 '16 at 16:20





...or the other way around - include this option for certain algos, but not as a global option.

– lukas.coenig
Jul 19 '16 at 16:20











2














Not much manual adjustment is needed! You only add
RestyleAlgo{options}
right before the algorithm definition you want to be overridden.



Note that options can be one of the followings: boxed, boxruled, ruled and algoruled.



Ex:



After defining usepachage{algorithm2e} in preamble:



     RestyleAlgo{ruled}
begin{algorithm}
....
end{algorithm}


That's it!






share|improve this answer


























  • Welcome to TeX.SE!

    – Kurt
    Mar 17 at 12:41
















2














Not much manual adjustment is needed! You only add
RestyleAlgo{options}
right before the algorithm definition you want to be overridden.



Note that options can be one of the followings: boxed, boxruled, ruled and algoruled.



Ex:



After defining usepachage{algorithm2e} in preamble:



     RestyleAlgo{ruled}
begin{algorithm}
....
end{algorithm}


That's it!






share|improve this answer


























  • Welcome to TeX.SE!

    – Kurt
    Mar 17 at 12:41














2












2








2







Not much manual adjustment is needed! You only add
RestyleAlgo{options}
right before the algorithm definition you want to be overridden.



Note that options can be one of the followings: boxed, boxruled, ruled and algoruled.



Ex:



After defining usepachage{algorithm2e} in preamble:



     RestyleAlgo{ruled}
begin{algorithm}
....
end{algorithm}


That's it!






share|improve this answer















Not much manual adjustment is needed! You only add
RestyleAlgo{options}
right before the algorithm definition you want to be overridden.



Note that options can be one of the followings: boxed, boxruled, ruled and algoruled.



Ex:



After defining usepachage{algorithm2e} in preamble:



     RestyleAlgo{ruled}
begin{algorithm}
....
end{algorithm}


That's it!







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 17 at 12:32









samcarter

93k7105300




93k7105300










answered Mar 17 at 12:22









SepidehaSepideha

211




211













  • Welcome to TeX.SE!

    – Kurt
    Mar 17 at 12:41



















  • Welcome to TeX.SE!

    – Kurt
    Mar 17 at 12:41

















Welcome to TeX.SE!

– Kurt
Mar 17 at 12:41





Welcome to TeX.SE!

– Kurt
Mar 17 at 12:41


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f279655%2falgorithm2e-override-defaults%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?