LaTex Tricks
TeXstudio has the Ctrl+T/U shortcuts for commenting/uncommenting multilines.
Comment in pseudocodes (Just for use with package algorithmic. For algorithmicx, simply use \Comment{})
\documentclass{article} \usepackage{algorithm,algorithmic} \usepackage{eqparbox} %\renewcommand{\algorithmiccomment}[1]{\hfill\eqparbox{COMMENT}{\# #1}} \renewcommand{\algorithmiccomment}[1]{\hfill\eqparbox{COMMENT}{/* #1 */}} \begin{document} \begin{algorithm} \begin{algorithmic}[1] \STATE $sum=0$; \FOR[comment for FOR]{$j=1$ \TO $100$} \IF[comment for IF]{$j\%2==1$} \STATE $sum=sum+i$; \COMMENT{normal comment} \ENDIF \ENDFOR \end{algorithmic} \end{algorithm} \end{document}
LaTex algorithm Packages (ACK:https://tex.stackexchange.com/questions/229355/algorithm-algorithmic-algorithmicx-algorithm2e-algpseudocode-confused)
- algorithm - float wrapper for algorithms.
- algorithmic - first algorithm typesetting environment.
- algorithmicx - second algorithm typesetting environment.
- algpseudocode - layout for
algorithmicx
. - algorithm2e - third algorithm typesetting environment.
I use algorithmicx
with algpseudocode
since they are superior to algorithmic
. I think algorithmicx
offers the same functionality compared to algorithm2e
, but I find its syntax clearer than the one provided by algorithm2e
.
Algorithm vs. Procedure (Ack https://qr.ae/pGOhuN)
A procedure which always terminates is called an algorithm.
The notion of a procedure and an algorithm is formally defined in the book “ Formal Languages and their relation to Automata “ (1969), by hopcroft and ullman. https://savedparadigms.files.wordpress.com/2014/09/formal-languages-and-their-relation-to-automata-john-e-hopcroft-jeffrey-d-ullman.pdf