0

How can I remove the indent after 'itemize'? I want 'algorithm 1...' to be written from the same place as header and first sentence.

Is there a better way than \qquad to format lines after 'Inputs:' and 'Outputs:' with indentation in the text?

\documentclass{article}
\documentclass[runningheads,a4paper]{article}
\usepackage[ruled,vlined]{algorithm2e}
\usepackage{calc}
\usepackage[a4paper,bindingoffset=0.2in,%
 left=0.5in,right=0.5in,top=0.5in,bottom=0.5in,%
 footskip=.25in]{geometry}
\usepackage{tabularx}
\newenvironment{algotabularx}
 {\tabularx{\linewidth-\inoutsize-\widthof{~~~}-4\tabcolsep-
\rightskip}[t]}
{\endtabularx} 


\begin{document}
\section{The Dijkstra’s algorithm}
The Dijkstra’s algorithm is used for finding shortest paths in a graph G = $\langle{V,E}\rangle$. The characteristics of the Dijkstra’s algorithm variant presented here are as follows:

\begin{itemize}
    \item Works on a \underline{weighted graph}.
    \item Only \underline{non-negative weights} are allowed.
    \item Calculates minimum distances from one node $v_0$ to all the others
    \item It has the complexity of $O(\left|V\right|^2)$.
\end{itemize}

Algorithm 1 presents a pseudocode for the Dijkstra’s algorithm.\\


\begin{algotabularx}{@{}p{3cm}p{0.5cm}p{10cm}X@{}} 

Inputs: \\
\qquad $G = \langle{V,E}\rangle$  & - & a weighted graph \\ 
\qquad $v_0$ & - & the initial node to determine distances from \\

Outputs: \\ 
\qquad $\forall v \in V : d(v)$ & - & a set of distances from $v0$ calculated for all nodes $v \in V$  \\
\qquad $\forall v \in V : d(p)$ & - & a set of predecessors on the shortest path from v0 \\

\end{algotabularx}

\end{document}

enter image description here

2
  • 1
    Just remove the blank line after \end{itemize}. – Bernard Nov 16 '20 at 11:41
  • Welcome to TeX.SE. Insert \noindent to suppress indentation. – Mico Nov 16 '20 at 11:46
1

The double line break after \end{itemize} indicates that you are starting a new paragraph, which causes the indentation. Remove one of the line breaks to indicate that it is part of the same paragraph:

\documentclass[runningheads,a4paper]{article}
\usepackage[ruled,vlined]{algorithm2e}
\usepackage{calc}
\usepackage[a4paper,bindingoffset=0.2in,%
left=0.5in,right=0.5in,top=0.5in,bottom=0.5in,%
footskip=.25in]{geometry}
\usepackage{tabularx}
\newenvironment{algotabularx}
{\tabularx{\linewidth-\inoutsize-\widthof{~~~}-4\tabcolsep-
        \rightskip}[t]}
{\endtabularx} 


\begin{document}
    \section{The Dijkstra’s algorithm}
    The Dijkstra’s algorithm is used for finding shortest paths in a graph G = $\langle{V,E}\rangle$. The characteristics of the Dijkstra’s algorithm variant presented here are as follows:
    
    \begin{itemize}
        \item Works on a \underline{weighted graph}.
        \item Only \underline{non-negative weights} are allowed.
        \item Calculates minimum distances from one node $v_0$ to all the others
        \item It has the complexity of $O(\left|V\right|^2)$.
    \end{itemize}   
    Algorithm 1 presents a pseudocode for the Dijkstra’s algorithm.\\
    
    
    \begin{algotabularx}{@{}p{3cm}p{0.5cm}p{10cm}X@{}} 
        
        Inputs: \\
        \qquad $G = \langle{V,E}\rangle$  & - & a weighted graph \\ 
        \qquad $v_0$ & - & the initial node to determine distances from \\
        
        Outputs: \\ 
        \qquad $\forall v \in V : d(v)$ & - & a set of distances from $v0$ calculated for all nodes $v \in V$  \\
        \qquad $\forall v \in V : d(p)$ & - & a set of predecessors on the shortest path from v0 \\
        
    \end{algotabularx}
    
\end{document}

leads to: 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.