0

I'm writing a report in which I describe numerous algorithms in the following way:

"[algorithm name]  
input: [input]  
output: [output]  
- step 1  
...  
- step n"  

My problem is that I'm also using the enumitem package to reduce the spacing between items and it adds an unwanted space between the output line and the beginning of the itemize.

\documentclass[a4paper,11pt]{article}  
\usepackage[shortlabels]{enumitem}  

\setlist[itemize]{noitemsep} 

\begin{document}  

algorithm name  
\textsc{input:} input  
\textsc{output:} output  
\begin{itemize}  
\item step 1  
\item step 2  
\item step 3  
\end{itemize}  
\end{document}

I tried making the first two lines part of the itemize by putting "input" and "output" as \item labels, but the difference in length makes them "right-aligned" (relatively to each other) and outside the body box.

  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – BambOo Aug 27 '18 at 11:23
  • I know this does not direclty address the question, but do you know the algotihmicx or algorithm2e packages ? They are specifically designed for the description of algorithms – BambOo Aug 27 '18 at 11:24
  • I've heard of these packages, however, the algorithms I describe are rather linear (no loops or anything similar) so I don't think using them would really help me. – Parker Aug 27 '18 at 11:45
0

Use nosep:

\documentclass[a4paper,11pt]{article}
\usepackage[shortlabels]{enumitem}

\begin{document}

algorithm name\\
\textsc{input:} input\\
\textsc{output:} output
\begin{itemize}[nosep]
\item step 1
\item step 2
\item step 3
\end{itemize}

\end{document} 

enter image description here

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.