Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How to remove the vertical space between item2 and the last line?

\documentclass[]{article}
\usepackage{enumerate}
\begin{document}
\title{Title}
\author{Author}
\date{\today}
\maketitle
\begin{tabular}{p{8cm}}
\hline
\textbf{Algorithm 1} \\
\hline
\begin{enumerate}[1:]
\item item1
\item item2
\end{enumerate}\\
\hline
\end{tabular}
\end{document}

enter image description here

share|improve this question

1 Answer 1

up vote 5 down vote accepted

You could switch from enumerate to enumitem and kill the vertical spacing of the enumerate; using the optional argument for \\ you can fine tune the vertical separation of the bottom rule. However, consider using some dedicated package, such as algorithmicx, for your algorithms (I included an example taken from the documentation for algpseudocode); manual numbering and formatting elements is not a good practice (you won't have easy cross-reference capabilities and the manual approach is error-prone):

\documentclass[]{article}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{enumitem}

\begin{document}
\title{Title}
\author{Author}
\date{\today}
\maketitle

\noindent\begin{tabular}{p{8cm}}
\hline
\textbf{Algorithm 1} \\
\hline
\begin{enumerate}[label=\arabic*:,nolistsep]
\item item1
\item item2
\end{enumerate}\\[-2ex]
\hline
\end{tabular}

\begin{algorithm}
\caption{Euclid’s algorithm}\label{euclid}
\begin{algorithmic}[1]
\Procedure{Euclid}{$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}
\State $a\gets b$
\State $b\gets r$
\State $r\gets a\bmod b$
\EndWhile\label{euclidendwhile}
\State \textbf{return} $b$\Comment{The gcd is b}
\EndProcedure
\end{algorithmic}
\end{algorithm}

\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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