# Tag Info

2

I believe the most natural way with KOMA-Script would be to declare a new float via \DeclareNewTOC the same way I used in my answer to New figure environment. Note that you have to add a \caption{} and compile twice to get the list updated the same way as with the default floats {figure} and {table}: \documentclass{scrartcl} \usepackage[T1]{fontenc} ...

3

1) You can easily turn your command into an environment with the same functionality (see code below): 2) and 3) Use \listofAlgorithmen \documentclass[a4paper, oneside, 12pt, listof=totoc, bibliography=totoc, titlepage, headinclude = false, footinclude = false, mpinclude = false, BCOR = 0mm, DIV = calc]{scrartcl} \usepackage[ngerman]{babel} ...

1

Yes, this can be done using the \algdef command. This is an example: \documentclass{article} \usepackage{algpseudocode} \algdef{SE}{PreLoop}{EndPreLoop}[1]{\textbf{preloop} $$\mbox{#1}$$ \textbf{do}}{\textbf{end}}% \begin{document} \begin{algorithmic}[1] \Procedure{Euclid}{$a,b$}\Comment{The g.c.d. of a and b} \State $r\gets a\bmod b$ ...

2

Let me try providing an answer. The example below uses algorithm2e. Of course related to your package the example must be modified. As often it shows how important a minimal working example (MWE) is. The modification must be done in several steps: Change the name of the list of. This is done by: \renewcommand\lstlistlistingname{Algorithms and program ...

6

The general idea should be this: you redefine an attribute of the "caption making" parameters of the algorithm environment so that it uses the same as lstlisting; what's needed is \ext@algorithm that contains the file extension of the auxiliary file where the caption should be written. \documentclass{report} \usepackage{listings} \usepackage{algorithm} ...

2

The contents lines and environment counters are added/incremented by \caption. So to change the list that an environment appears on, the caption command can be modified/extended. To keep the two environments in numerical sequence (ie as if they were the same environment) one can be incremented when the other is caption'd. \documentclass{report} ...

1

If you're willing to use \TitleOfAlgo instead (which, for algorithms, is more flexible than \caption in many ways), then see John Wickerson's answer. Otherwise, if you really want to use \caption but remove algorithm numbering, simply insert \renewcommand{\thealgocf}{} in your preamble. \documentclass[10pt]{report} \usepackage{algorithm2e} ...

1

As texenthusiast has pointed out in a comment below, you should use \TitleOfAlgo{How to write algorithms} rather than \caption{How to write algorithms} This makes algorithms not numbered by default. If you change your mind and want the algorithms to be numbered again, you should set the option titlenumbered option when you load the algorithm2e ...

0

I haven't managed to get [algorithmicx] working directly inside a frame either. I was wrong in assuming that mdframed was to blame: it was cleveref interfering. When that detects a package called algorithm, it will try to modify its code, apparently breaking things for algorithmicx. By not including that package, things worked a lot better. At some ...

3

You have to use the correct loading order; check also Which packages should be loaded after hyperref instead of before? \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} % hyperref must go last \usepackage{hyperref} % but cleveref goes "laster" than hyperref \usepackage[nameinlink,noabbrev]{cleveref} ...

3

Adding \addtocounter{algorithm}{-1} before issuing the \caption command in the second algorithm environment solves the problem. However, this (and also the \ContinuedFloat approach) will break hyperref linking mechanism, if this package is used. \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} %\usepackage{hyperref} %%% add the ...

3

As egreg has mentioned in a comment, one option would be to use \addtocounter{algorithm}{-1} before \caption{Part 2}. Another option, not requiring manually changing counters and that additionally gives you the possibility to use a customized formatting for the continued algorithm, would be to use \ContinuedFloat from the caption package. An example ...

0

Ok, I laugh when I think about it... The solution is very simple: it's enough add a space between commas. \begin{algorithm} \caption{Algorithm to fetch overlapped objects from input lists.} \begin{algorithmic}[1] \Procedure {CHECK\_OVERLAP}{$List\_Global\_RE\_To\_Ev\_Objs\_A_k$, $List\_Global\_RE\_To\_Ev\_Objs\_B_k$} \EndProcedure \Statex \end{algorithmic} ...

3

For your comment, use \renewcommand{\algorithmiccomment}[1]{\hfill(#1)\ignorespaces} which gobbles any spaces after \COMMENT, effectively being the same as inserting % after each one. See What is the use of percent signs (%) at the end of lines?

2

A work around is to comment out the end of line characters after the \COMMENT commands: \documentclass{article} \usepackage{algorithmic} \renewcommand{\algorithmiccomment}[1]{\hfill(#1)} \usepackage{hyperref} \begin{document} \begin{algorithmic} \STATE foo \COMMENT{bar}% \FOR{foo} \STATE foo \COMMENT{bar}% \STATE foo \COMMENT{bar}% ...

2

Add \Statex for an unnumbered line (or \State for a numbered one): \documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \begin{algorithm}[t] \begin{algorithmic}[1] \Function{Euclid1}{$a,b$}\Comment{The g.c.d. of a and b} \State $r\gets a\bmod b$ \While{$r\not=0$}\Comment{We have the answer if r is 0} ...

2

You may try out listings, which in the first place provides solutions to typeset program code instead of pseudo code. Allthough i think that it could work out. For instance i used it in a numerical mathematics lecture to typeset Matlab code. Since Matlab is very generic and close to Pseudo, this could fit to your problem: ...

4

Here's one possibility (the code conatains explanatory comments; see also below): \documentclass[fontsize=12pt,a4paper,final,parskip=full]{scrreprt} \usepackage{listings} \usepackage{xcolor} \usepackage[boxed]{algorithm} \usepackage[noend]{algpseudocode} \usepackage{bera}% nice monospaced font with possibility for boldfaced characters ...

Top 50 recent answers are included