If possible, I want to align condition statements like: \If
, \Else
, \For
statements in between \begin{algorithmic} ... \end{algorithmic}
section.
example:
\begin{algorithmic}[1]
\For{a for statement} | for a for stament
\If{some coding} | if some coding
\State do something | do something
\EndIf |
\EndFor |
\If{some coding} | if some coding
\State do something | do something
\EndIf
\end{algorithmic}
Following example latex
code taken from: https://tex.stackexchange.com/a/615852/127048.
When I select all lines in the buffer an press (TAB indent-for-tab-command
) it aligns all if else statements in the same vertical line. In python-mode
indent-for-tab-command
successfully align indents.
\documentclass{article}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\begin{document}
\begin{algorithm}
\caption{Main D Algorithm}\label{alg:cap}
\begin{algorithmic}[1]
\For{a for statement}
\If{some coding}
\State do something
\ElsIf{another condition}
\For{some condition}
\If{another statement}
\State do something
\EndIf
\EndFor
\ElsIf{problem is here}
\State whatever
\EndIf
\EndFor
\end{algorithmic}
\end{algorithm}
\end{document}
After TAB indent-for-tab-command
the buffer is converted into:
\documentclass{article}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\begin{document}
\begin{algorithm}
\caption{Main D Algorithm}\label{alg:cap}
\begin{algorithmic}[1]
\For{a for statement}
\If{some coding}
\State do something
\ElsIf{another condition}
\For{some condition}
\If{another statement}
\State do something
\EndIf
\EndFor
\ElsIf{problem is here}
\State whatever
\EndIf
\EndFor
\end{algorithmic}
\end{algorithm}
\end{document}
Environmet: algorithmic Function: current-indentation