3

I am using algorithm package in order to create a pseudocode. But I would like to modify the way it appears some lines.

Here is my code:

\documentclass[twoside,12pt]{book}
\usepackage{algorithm}
\usepackage{algorithmic}

\begin{document}

\begin{algorithm}
\begin{algorithmic}[1]
\STATE{Actividades Programadas}
\STATE Construcción de Soluciones
\STATE Actualización de feromona
\STATE Acciones del demonio
\end{algorithmic}
\caption{Procedimiento de ACO}\label{alg:algoritmoRaro}
\end{algorithm}

\end{document}

I would like the text "Actividades Programadas" to appear in bold and with not number. Also Construcción de Soluciones, Actualización de feromona, Acciones del demonio to be number and indented.

4

Below I provide \nonumSTATE to set a regular \STATE without the numbering. Also, \BEGININDENT...\ENDINDENT is an environment that indents its contents.

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{algorithm,algorithmic}

\makeatletter
\newcommand{\nonumSTATE}{\item[]}
\newcommand{\BEGININDENT}{\begin{ALC@g}}
\newcommand{\ENDINDENT}{\end{ALC@g}}
\makeatother

\begin{document}

\begin{algorithm}
  \begin{algorithmic}[1]
    \nonumSTATE {\bfseries Actividades Programadas}
    \BEGININDENT
      \STATE Construcción de Soluciones
      \STATE Actualización de feromona
      \STATE Acciones del demonio
    \ENDINDENT
  \end{algorithmic}
  \caption{Procedimiento de ACO}
\end{algorithm}

\end{document}

Setting the \nonumSTATE to be bold automatically is possible (for example, if you write your code to supply the content as an argument - like you did in the original post), but using \textbf or \bfseries seems sufficient.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.