4

I created a pseudocode algorithm like this:

enter image description here

% Pseudo code %
\usepackage{amsmath}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\algdef{SE}{Begin}{End}{\textbf{begin}}{\textbf{end}}

\begin{algorithm}
\caption{Pseudocodice algoritmo Apriori}
\label{alg:pseudoApriori}
\renewcommand{\thealgorithm}{}
\floatname{algorithm}{}
\begin{algorithmic}[1]
    \Begin
    \State $L_{1} = \{Frequent - 1itemset\} $
    \State $k \leftarrow 2$
    \While {$L_{k-1} \neq \phi$}
    \State $Temp \leftarrow candidateItemSet (L_{k-1})$
    \State $C_{k} \leftarrow frequencyOfItemSet (Temp)$
    \State $L_{k} \leftarrow compareItemSetWithMinSup (C_{k}, minsup) $
    \State $k \leftarrow k + 1$
    \EndWhile
    \State \Return L
    \End
\end{algorithmic}\end{algorithm}

Now I'd like to remove the header (above the first line of code) and remove the line numbering; How could I do these two things easily (being a latex/algorithmc newbie)?

The thing is I'd like to use this kind of style not only for writing algoritms but for random lines of code too.

2
  • Welcome to TeX SX! Why did you write a caption text, if you don't want a header?
    – Bernard
    Apr 13 '17 at 8:49
  • Hi @Bernard , ty. I actually changed my mind about how to display code/algorithms in my tex; In the precedent style caption was needed but now I'd like to remove them. You want me to edit question? Apr 13 '17 at 9:31
1

To remove the caption just don't write a caption command. To remove line numbers, omit the option argument [1] at the \begin{algorithmic}:

Sample output

\documentclass{article}

\usepackage{amsmath}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\algdef{SE}{Begin}{End}{\textbf{begin}}{\textbf{end}}

\begin{document}

\begin{algorithm}
  \begin{algorithmic}
    \Begin
    \State $L_{1} = \{Frequent - 1itemset\} $
    \State $k \leftarrow 2$
    \While {$L_{k-1} \neq \phi$}
    \State $Temp \leftarrow candidateItemSet (L_{k-1})$
    \State $C_{k} \leftarrow frequencyOfItemSet (Temp)$
    \State $L_{k} \leftarrow compareItemSetWithMinSup (C_{k}, minsup) $
    \State $k \leftarrow k + 1$
    \EndWhile
    \State \Return L
    \End
  \end{algorithmic}
\end{algorithm}

\end{document}
2
  • how to remove the border next, i would like to do that. Mar 23 '18 at 7:40
  • 1
    @LancePollard That is really a separate question, but just use the plain option to the algorithm package (standard is ruled, other possibility is boxed). Mar 23 '18 at 8:29

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.