Tag Info

New answers tagged

1

The following segment of code makes an entire copy of the macros involved with \listoffigures, applying them to a redefined \listofalgorithms: \usepackage{etoolbox} \makeatletter \AtBeginDocument{% \let\l@algorithm\l@figure% \let\listofalgorithms\listoffigures% Copy \listoffigures \let\@cftmakeloatitle\@cftmakeloftitle% Copy LoF title % Update ...


2

There are doubtless many, many reasons not to do this... Caveat emptor... The idea is essentially to write the list of algorithms to the auxiliary files twice. We let the algorithm package do its own thing: it has its own counter, its own contents lines, its own format. The lot. We just never print the list of algorithms it produces. Instead, we modify ...


1

You can use a \parbox (with \raggedright text if too narrow): \documentclass{article} \usepackage[table,dvipsnames]{xcolor} \usepackage{algorithm,algpseudocode,float} %----------- \makeatletter \newenvironment{breakablealgorithm} {% \begin{breakablealgorithm} \begin{center} \refstepcounter{algorithm}% New algorithm \hrule height.8pt depth0pt ...


1

You have to define a new float style: \documentclass{article} \usepackage{algorithm,algorithmic} \makeatletter \newcommand\floatc@ruled@gabriel[2]{#2\par} \newcommand\fs@ruledgabriel{% \def\@fs@cfont{\bfseries}\let\@fs@capt\floatc@ruled@gabriel \def\@fs@pre{% {\@fs@cfont\strut\fname@algorithm\ \thealgorithm}\par \hrule height.8pt depth0pt ...


2

algorithm uses the float package which defines a H float specifier. Without loading algorithm, your \begin{table}[H] ... \end{table} actually produces an error stating "Unknown float option H". LaTeX does recover from this error though and then defaults to something different, which changes the display to a page-of-floats-like layout (which has the ...


2

Define: \algdef{SE}[SUBALG]{Indent}{EndIndent}{}{\algorithmicend\ }% \algtext*{Indent} \algtext*{EndIndent} Then in the algorithmic block, write: \begin{algorithmic}[1] \State Outside indent block \Indent \State Inside indent block \EndIndent \end{algorithmic}


1

The method is explained in section 4.4 (Customization) of the package manual (pages 15–16): \floatname{algorithm}{Code snippet} Full example \documentclass{article} \usepackage{algorithm} \usepackage{listings} \floatname{algorithm}{Code snippet} \begin{document} \begin{algorithm} \caption{Description} \label{alg:num} %\lstset{language=custom} ...


1

You can redefine \ALG@name \documentclass{article} \usepackage{algorithm} \usepackage{listings} \makeatletter \edef\ALG@name{Code snippets} \makeatother \begin{document} \begin{algorithm} \caption{Description} \label{alg:num} %\lstset{language=custom} \begin{lstlisting} my code \end{lstlisting} \end{algorithm} \end{document}


1

The following does not allow for nesting of loop structures within each other, but provides the sub-numbering of a pseudo-code grouping (like \FOR, \WHILE, \LOOP and \REPEAT): \documentclass{article} \usepackage{algorithm,algorithmic,xpatch} \makeatletter \xpatchcmd{\algorithmic}% <cmd> {\arabic{ALC@line}}% <search> {\theALC@line}% ...


3

Consider using \Require instead of \REQUIRE. LaTeX is case-sensitive. Here's a small example with \Require which I made for my next LaTeX book, as a demo showing several features. \documentclass{article} \usepackage{dsfont} \usepackage{algorithm} \usepackage{algorithmicx} \usepackage{algpseudocode} \usepackage{mathtools} \newcommand{\minbox}[2]{% ...


1

To remove only the name "Algorithm" from the caption you can use the caption package and declare a format for the label using \DeclareCaptionLabelFormat (see example below); if you want to suppress the name and the numbering, you can use \captionsetup[algorithm]{labelformat=empty} To facilitate indentation I defined two commands \bindent (begin ...


0

Updating the packages algorithmicx and algorithms did not help, but indeed the problem was that on one machine one of the packages was outdated. After a thorough search/comparison of the package dates in the MiKTeX Package Manager on both machines, I found that on one system the package caption had a different date than the other. Uninstalling the older ...



Top 50 recent answers are included