# Tag Info

4

Use \SetInd{<space before>}{<space after>} to control the spacing before and after the vertical rule (which is disabled via that noline option). Here is a comparison of the default setting and one with \SetInd{0.25em}{0.1em}: Code: \documentclass{article} ...

3

To force a float to remain in a specific location, add the float package to your preamble \usepackage{float}% http://ctan.org/pkg/float and use the [H] float placement specifier. Done. \documentclass{article} \usepackage[margin=1in]{geometry}% For this example \usepackage{algorithm,algpseudocode,float} \usepackage{lipsum}% For this example ...

1

There are two kinds of environments in algorithmicx. One is algorithmic, which typesets algorithms very much like normal text. This will stay between two paragraphs, if you put it there, but it will break across pages. The other is algorithm, which is a floating object. This means that it can get a caption, it will stay on one page and LaTeX will try to ...

5

This is what can be done with algorithmicx: Code: \documentclass{article} \usepackage{amsmath} \usepackage{algorithm} \usepackage[noend]{algpseudocode} \makeatletter \def\BState{\State\hskip-\ALG@thistlm} \makeatother \begin{document} \begin{algorithm} \caption{My algorithm}\label{euclid} \begin{algorithmic}[1] \Procedure{MyProcedure}{} \State ...

6

I think loading the package caption is the appropriate way. \usepackage{caption} \DeclareCaptionLabelFormat{alglabel}{\bfseries\csname ALG@name\endcsname:} \captionsetup[algorithm]{labelformat=alglabel} \documentclass{article} \usepackage[english]{babel} \usepackage{algorithmic} \usepackage{algorithm} \makeatletter ...

2

You can define a new block structure \Event...\EndEvent to suit your needs: \documentclass{article} \usepackage{amsmath,algpseudocode}% http://ctan.org/pkg/{amsmath,algorithmicx} \algdef{SE}[EVENT]{Event}{EndEvent}[1]{\textbf{upon event}\ #1\ \algorithmicdo}{\algorithmicend\ \textbf{event}}% \algtext*{EndEvent} \begin{document} \begin{algorithmic}[0] ...

5

You need to define a command with an argument giving the font specification and then use the name of this command in the argument for \SetCommentSty: \documentclass{article} \usepackage{xcolor} \usepackage[linesnumbered,ruled,vlined]{algorithm2e} \newcommand\mycommfont[1]{\footnotesize\ttfamily\textcolor{blue}{#1}} \SetCommentSty{mycommfont} ...

4

You have tried to use the @ character in a command name, which is not directly possible, you have to 'mask' it with the commands \makeatletter before using the other command and afterwards change it back to \makeatother, see my code below. \documentclass{scrreprt} \usepackage{algorithm} \usepackage{algorithmicx} \usepackage{algpseudocode} ...

4

You are using incompatible commands from the packages algorithm2e and algpseudocode; you can use only algpseudocode and replace \KwData, \KwResult with \Require, \Ensure: \documentclass[conference]{IEEEtran} \usepackage[spanish, es-tabla]{babel} \usepackage{amsmath} \usepackage{algorithm} \usepackage{algpseudocode} \begin{document} \begin{algorithm} ...

2

Your code is compiling just fine. I've made the parentheses a bit smaller and used the left/right versions of them to get better horizontal spacing. Also, there were unnecessary ampersands. Version 1: \documentclass[oneside]{book} \usepackage[fleqn]{amsmath} \setlength\mathindent{0pt} \begin{document} \begin{flalign} x \in A \cap (B \cup C) ...

3

This code works. I removed big brackets to have the same space between equations \documentclass[oneside]{book} \usepackage[fleqn]{amsmath} \setlength{\mathindent}{0pt} \begin{document} \begin{flalign} x \in A \cap (B \cup C) & \Rightarrow (x \in A) \lambda \left( (x \in B)\vee(x \in C) \right) & \\ & \Rightarrow \left( (x ...

2

This code works for me: \documentclass[oneside]{book} \usepackage[fleqn]{amsmath} \setlength{\mathindent}{0pt} \begin{document} \begin{flalign} x \in A \cap (B \cup C) & \Rightarrow (x \in A) \lambda \Big( (x \in B)\vee(x \in C) \Big) & \\ & \Rightarrow \Big( (x \in A) \lambda (x \in B) \Big) \vee \Big( (x \in A)\lambda (x \in C) \Big) ...

0

If you like the typesetting used in the Introduction to Algorithm, here is the page for clrscode, which includes package for both the second and third edition.

5

To restart line numbering from 1, you have to reset the counter ALG@line, so we define a new command \resetline to be issued when you want that change: \makeatletter \newcommand{\resetline}{\setcounter{ALG@line}{0}} \makeatother In regards of the spacing between two functions, you can use a normal skip instead of issuing a \Statex (\smallskip, \medskip, ...

Top 50 recent answers are included