Skip to content

Commit 103ebf7

Browse files
committed
Added package options to documentation.
1 parent db58c2f commit 103ebf7

File tree

2 files changed

+247
-2
lines changed

2 files changed

+247
-2
lines changed

algpseudocodex.sty

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@
4141

4242
\DeclareBoolOption[true]{noEnd}% don't print end if etc.
4343
\DeclareBoolOption[true]{indLines}% show indent guide lines
44+
\DeclareBoolOption[true]{spaceRequire}% adds vertical space before \Require if not in first line
4445
\DeclareBoolOption[true]{italicComments}% italicise comments
4546
\DeclareBoolOption[true]{rightComments}% right justify comments
46-
\DeclareBoolOption[true]{spaceRequire}% adds vertical space before \Require if not in first line
47+
\DeclareStringOption[gray]{commentColor}% color of comments
4748
\DeclareStringOption[$\triangleright$~]{beginComment}% print at beginning of comment
4849
\DeclareStringOption[]{endComment}% print at end of comment
4950
\DeclareStringOption[$\triangleright$~]{beginLComment}% print at beginning of long comment
5051
\DeclareStringOption[~$\triangleleft$]{endLComment}% print at end of long comment
51-
\DeclareStringOption[gray]{commentColor}% color of comments
5252
\ProcessLocalKeyvalOptions*
5353

5454

documentation.tex

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,4 +359,249 @@ \subsubsection*{Example}
359359
\end{algorithmic}
360360
\end{minipage}
361361

362+
363+
\section{Package Options}
364+
When loading \texttt{algpseudocodex} the options describe in this section can be set. They syntax for setting \verb|option1| to \verb|value1| and \verb|option2| to \verb|value2| is:
365+
\begin{verbatim}
366+
\usepackage[option1=value1,option2=value2]{algpseudocodex}
367+
\end{verbatim}
368+
369+
\subsection{noEnd}
370+
\begin{description}
371+
\item[possible values:] \verb|true|, \verb|false|
372+
\item[default:] \verb|true|
373+
\end{description}
374+
If \verb|false|, the end of blocks are marked with the expression ``end'' followed by the name of the block.
375+
376+
\subsubsection*{Example}
377+
\begin{minipage}[t]{0.45\textwidth}
378+
\verb|noEnd=false|:
379+
\begin{algorithmic}
380+
\makeatletter
381+
\setbool{algpx@noEnd}{false}%
382+
\algtext{EndIf}{\algpx@endIndent\algpx@startCodeCommand\algorithmicend\ \algorithmicif%
383+
\algpx@startIndent% \EndIf ends another indent. Start fake one here to handle that.
384+
}
385+
\makeatother
386+
\If{$x > 0$}
387+
\State $x \gets x - 1$
388+
\EndIf
389+
\end{algorithmic}
390+
\end{minipage}
391+
\hfill
392+
\begin{minipage}[t]{0.45\textwidth}
393+
\verb|noEnd=true|:
394+
\begin{algorithmic}
395+
\If{$x > 0$}
396+
\State $x \gets x - 1$
397+
\EndIf
398+
\end{algorithmic}
399+
\end{minipage}
400+
401+
402+
\subsection{indLines}
403+
\begin{description}
404+
\item[possible values:] \verb|true|, \verb|false|
405+
\item[default:] \verb|true|
406+
\end{description}
407+
If \verb|true|, indent guide lines are drawn.
408+
409+
\subsubsection*{Example}
410+
\begin{minipage}[t]{0.45\textwidth}
411+
\verb|indLines=false|:
412+
\begin{algorithmic}
413+
\makeatletter
414+
\setbool{algpx@indLines}{false}%
415+
\makeatother
416+
\If{$x > 0$}
417+
\State $x \gets x - 1$
418+
\EndIf
419+
\end{algorithmic}
420+
\end{minipage}
421+
\hfill
422+
\begin{minipage}[t]{0.45\textwidth}
423+
\verb|indLines=true|:
424+
\begin{algorithmic}
425+
\If{$x > 0$}
426+
\State $x \gets x - 1$
427+
\EndIf
428+
\end{algorithmic}
429+
\end{minipage}
430+
431+
432+
\subsection{spaceRequire}
433+
\begin{description}
434+
\item[possible values:] \verb|true|, \verb|false|
435+
\item[default:] \verb|true|
436+
\end{description}
437+
If \verb|true|, vertical space is added before every \verb|\Require| except the one on the first line. This is useful for specifying different behaviors depending on the provided input.
438+
439+
\subsubsection*{Example}
440+
\begin{minipage}[t]{0.45\textwidth}
441+
\verb|spaceRequire=false|:
442+
\begin{algorithmic}
443+
\makeatletter
444+
\setbool{algpx@spaceRequire}{false}%
445+
\makeatother
446+
\Require $x \in \{0,1\}$
447+
\State \Return $x$
448+
\Require $x \in \{1,2\}$
449+
\State \Return $x-1$
450+
\end{algorithmic}
451+
\end{minipage}
452+
\hfill
453+
\begin{minipage}[t]{0.45\textwidth}
454+
\verb|spaceRequire=true|:
455+
\begin{algorithmic}
456+
\Require $x \in \{0,1\}$
457+
\State \Return $x$
458+
\Require $x \in \{1,2\}$
459+
\State \Return $x-1$
460+
\end{algorithmic}
461+
\end{minipage}
462+
463+
464+
\subsection{italicComments}
465+
\begin{description}
466+
\item[possible values:] \verb|true|, \verb|false|
467+
\item[default:] \verb|true|
468+
\end{description}
469+
If \verb|true|, all comments are typeset in italic font. If \verb|false|, comments are typeset in roman font.
470+
471+
\subsubsection*{Example}
472+
\begin{minipage}[t]{0.45\textwidth}
473+
\verb|italicComments=false|:
474+
\begin{algorithmic}
475+
\makeatletter
476+
\setbool{algpx@italicComments}{false}%
477+
\makeatother
478+
\LComment{Long comment.}
479+
\State $x \gets 0$ \Comment{Short comment.}
480+
\end{algorithmic}
481+
\end{minipage}
482+
\hfill
483+
\begin{minipage}[t]{0.45\textwidth}
484+
\verb|italicComments=true|:
485+
\begin{algorithmic}
486+
\LComment{Long comment.}
487+
\State $x \gets 0$ \Comment{Short comment.}
488+
\end{algorithmic}
489+
\end{minipage}
490+
491+
492+
\subsection{rightComments}
493+
\begin{description}
494+
\item[possible values:] \verb|true|, \verb|false|
495+
\item[default:] \verb|true|
496+
\end{description}
497+
If \verb|true|, comments typeset with \verb|\Comment| are right justified on the current line. If a comment does not fit on the current line, no justification is applied. If \verb|false|, all comments are typeset right after the end of the current line.
498+
499+
Does not affect long comments typeset with \verb|\LComment|.
500+
501+
\subsubsection*{Example}
502+
\begin{minipage}[t]{0.45\textwidth}
503+
\verb|rightComments=false|:
504+
\begin{algorithmic}
505+
\makeatletter
506+
\setbool{algpx@rightComments}{false}%
507+
\makeatother
508+
\LComment{No effect on long comments.}
509+
\State $x \gets 0$ \Comment{Short comment.}
510+
\State $x \gets x^2$ \Comment{Does not fit on the current line and is thus not justified.}
511+
\end{algorithmic}
512+
\end{minipage}
513+
\hfill
514+
\begin{minipage}[t]{0.45\textwidth}
515+
\verb|rightComments=true|:
516+
\begin{algorithmic}
517+
\LComment{No effect on long comments.}
518+
\State $x \gets 0$ \Comment{Short comment.}
519+
\State $x \gets x^2$ \Comment{Does not fit on the current line and is thus not justified.}
520+
\end{algorithmic}
521+
\end{minipage}
522+
523+
524+
\subsection{commentColor}
525+
\begin{description}
526+
\item[possible values:] Any color that can be used in \verb|\textcolor|.
527+
\item[default:] \verb|gray|
528+
\end{description}
529+
Defines the color in which comments are typeset.
530+
531+
\subsubsection*{Example}
532+
\begin{minipage}[t]{0.45\textwidth}
533+
\verb|commentColor=black|:
534+
\begin{algorithmic}
535+
\makeatletter
536+
\renewcommand{\algpx@commentColor}{black}%
537+
\makeatother
538+
\LComment{Long comment.}
539+
\State $x \gets 0$ \Comment{Short comment.}
540+
\end{algorithmic}
541+
\end{minipage}
542+
\hfill
543+
\begin{minipage}[t]{0.45\textwidth}
544+
\verb|commentColor=blue|:
545+
\begin{algorithmic}
546+
\makeatletter
547+
\renewcommand{\algpx@commentColor}{blue}%
548+
\makeatother
549+
\LComment{Long comment.}
550+
\State $x \gets 0$ \Comment{Short comment.}
551+
\end{algorithmic}
552+
\end{minipage}
553+
554+
555+
\subsection{beginComment and endComment}
556+
\begin{description}
557+
\item[possible values:] Any string that can be typeset in text mode.
558+
\item[default:] \verb|$\triangleright$~| and (empty)
559+
\end{description}
560+
Used to indicate the beginning and end of comments typeset with \verb|\Comment|, respectively.
561+
562+
\subsubsection*{Example}
563+
\begin{minipage}[t]{0.45\textwidth}
564+
\verb|beginComment=//~|:
565+
\begin{algorithmic}
566+
\makeatletter
567+
\renewcommand{\algpx@beginComment}{//~}%
568+
\makeatother
569+
\LComment{Long comment.}
570+
\State $x \gets 0$ \Comment{Short comment.}
571+
\end{algorithmic}
572+
\end{minipage}
573+
\hfill
574+
\begin{minipage}[t]{0.45\textwidth}
575+
\verb|beginComment=/*~|, \verb|endComment=~*/|:
576+
\begin{algorithmic}
577+
\makeatletter
578+
\renewcommand{\algpx@beginComment}{/*~}%
579+
\renewcommand{\algpx@endComment}{~*/}%
580+
\makeatother
581+
\LComment{Long comment.}
582+
\State $x \gets 0$ \Comment{Short comment.}
583+
\end{algorithmic}
584+
\end{minipage}
585+
586+
\subsection{beginLComment and endLComment}
587+
\begin{description}
588+
\item[possible values:] Any string that can be typeset in text mode.
589+
\item[default:] \verb|$\triangleright$~| and \verb|~$\triangleleft$|
590+
\end{description}
591+
Used to indicate the beginning and end of long comments typeset with \verb|\LComment|, respectively.
592+
\subsubsection*{Example}
593+
\begin{minipage}[t]{0.45\textwidth}
594+
\verb|beginLComment=/*~|, \verb|endLComment=~*/|:
595+
\begin{algorithmic}
596+
\makeatletter
597+
\renewcommand{\algpx@beginLComment}{/*~}%
598+
\renewcommand{\algpx@endLComment}{~*/}%
599+
\makeatother
600+
\LComment{Long comment.}
601+
\State $x \gets 0$ \Comment{Short comment.}
602+
\end{algorithmic}
603+
\end{minipage}
604+
605+
606+
362607
\end{document}

0 commit comments

Comments
 (0)