New answers tagged

2

Here is a way to achieve what you want... Use \addtocounter{algocf}{-1} to reduce the Algorithm counter before setting a countinued algorithm. Use \strut as part of the caption to ensure that they present at a similar height if you want to avoid a "jumping" effect when skipping between pages. Mark the end of an algorithm with a \label that you can use to ...


0

I have found a solution from other topics, though not the most elegant one I suppose. You can do it with minpages but then you have to give your algorthm environment the [H] specifier such that it isn't a float anymore. I'd prefer if it would remain a float but it will do... Here's an example \begin{center} \begin{minipage}{0.7\textwidth} ...


0

Do not auto-enumerate the lines. Instead, set those that require a number using \nl and those that require something else with \nlset{<stuff>}: \documentclass[conference]{IEEEtran} \usepackage[ruled]{algorithm2e} \begin{document} \begin{algorithm} \nl $\pi=1$\; \nlset{*} $\Phi = 2$\; \nl $\pi = 3$\; \end{algorithm} \end{document} Another ...


0

I was using \usepackage{stfloats}. Removing the package solved my issue.


0

\documentclass{article} \usepackage{amsmath} \begin{document} \begin{verbatim} if (some condition) P=P+($W_i*((W-P)/W_i$))\\ end \end{verbatim} \begin{align*} P &= P + W_{i}*((W-P)/W_{i})\\ P &= P + \frac{W_{i}*(W-P)}{W_{i}}\\ \end{align*} \end{document}


0

The example you showed has unbalanced braces and $. Generally, if you want to to type multiline maths, it is not sufficient to separate the lines with blank line as you do in ordinary text. You need to use special environments like align, gather, split, aligned, gathered etc. The new lines / rows are signalled with \\ instead of blank lines (like you do in ...


2

algorithm2e's \caption has the following format: \AlCapSty{\AlCapFnt Algorithm 1:}\AlCapNameSty{\AlCapNameFnt my algorithm} Taken from the "change log": By default, \AlCapSty is \textbf and \AlCapFnt is nothing. \AlCapNameSty keep text as it is, and \AlCapNameFnt do nothing also. You can redefine \AlCapFnt and \AlCapNameFnt by giving macro to ...


0

Well, I do not know what you want to do with the command \useothernumberingtrue, but that command throws in the following compiling MWE (I have commented this command out!) 5 errors. Please explain in your question what the given code should do ... The following MWE compiles without errors (please see my changings, I commented all packages or commands not ...


2

In my point of view this is best achieved with a SubAlgoLine counter and an conditional within \theAlgoLine (which prints the line number) \documentclass{article} \usepackage{amsmath, amsfonts, amssymb, amsthm, bm} \usepackage{commath} \usepackage{xcolor} \usepackage[most]{tcolorbox} \usepackage{tikz} \usetikzlibrary{backgrounds} ...


1

You have to use \titlecontents{algocf} because the package algorithm2e stores the captions as \contentsline{algocf}{...} in the .loa file. However, this package doesn't seem to be wanting to cooperate with titletoc that's unable to initialize one of its variables, so we need to give some help. \documentclass{book} ...


4

Some points: align cannot see a & that is inside a TikZ node. Put E_s &= outside the \tikz-picture. \subnode should be used as \subnode{d4}{$X$}, not \subnode(d4){$X$} (note braces). And you need to set the baseline of the the tikzpicture to something useful. \documentclass{article} \usepackage{amsmath, amsfonts, amssymb, amsthm, bm} ...


1

Change the \caption command line to \caption{\color{blue} \textbf{\textit{Unnumbered lines}}} and compile you will get:


1

\documentclass{article} \usepackage{tikz} \usepackage{xcolor} \usepackage{algorithm2e} \definecolor{mybluei}{RGB}{0,173,239} \begin{document} \begin{center} \colorbox{mybluei}{\color{red} \begin{minipage}{0.85\textwidth} \SetAlgoLined \SetNlSty{textbf}{}{:} \begin{algorithm}[H] \DontPrintSemicolon This is line one\\ This is line two numbered\\ This should be ...


3

This is how I do to center an algorithm with a gray background : \begin{center} \colorbox[gray]{0.95}{ \begin{minipage}{0.65\textwidth} \SetAlgoLined \SetNlSty{textbf}{}{:} \begin{algorithm}[H] \DontPrintSemicolon This is line one\\ This is line two numbered\\ This should be numbered\\ This should also be numbered \caption{Unnumbered lines} \end{algorithm} ...


1

The problem is as a result of you mixing two incompatible algorithm packages. algorithm2e provides both the algorithm environment as well as the syntax macros for writing pseudocode. algpseudocode provides only syntax macros. You should use either algorithm2e or algpseudocode (and algorithm), but not both. Here is a rough algorithm2e implementation of what ...


2

From revision 2.40 of algorithm2e, it provides \SetKwComment{<cmd>}{<before>}{<after>} which creates the command <cmd>, setting some content <before> and some <after> the comment. You can redefine the way the existing macros function using the above. Here's how \tcp is defined originally: \SetKwComment{tcp}{// }{}% ...


1

You need to provide \\ as a string, not \\, otherwise it would be interpreted as \newline instruction, causing the error about Missing item \documentclass{article} \usepackage[lined,boxed,commentsnumbered]{algorithm2e} \SetKwComment{tcp}{\tiny \string\\}{} \begin{document} \begin{algorithm} \tcp*[l]{ {\tiny Here is my comment.} } \end{algorithm} ...


1

Is perhaps this that you want? \documentclass[12pt]{report} \usepackage[ruled,linesnumbered]{algorithm2e} \usepackage{amsmath} \begin{document} \begin{algorithm} \DontPrintSemicolon \caption{BE radix-8 IMML Modular Multiplication}\label{alg1} \KwIn{ $x=\sum_{i=0}^{n-1} x_i\cdot2^i$, $y=\sum_{i=0}^{n-1} y_i\cdot2^i$, $p=\sum_{i=0}^{n-1}p_i\cdot2^i$ ...


0

A first version, not complete so far! The \SetKwX macros define much of the keywords and appearance style, but not all is possible, apparently, without manual interaction on the precise position when the \ForAll etc. statements are used. \documentclass[10pt,a4paper]{article} \usepackage[lined,boxed,commentsnumbered,german]{algorithm2e} ...



Top 50 recent answers are included