1

I am using algorithmicx to typeset my algorithms in XeTeX. Using fontspec, I set the default font to be Linux Libertine with historical ligatures (e.g., ct, st). Unfortunately, this is also the font used by algorithmicx to typeset my algorithms and historical ligatures look very much out of place there.

This is likely a newbie question, but is there any way to customize the font used within the algorithmic environment without specifying the custom font at the beginning of each such environment?

A simple solution is to define a new environment

\newenvironment{halgorithmic}
   { \begin{algorithmic}\algofont }
   { \end{algorithmic} }

and use halgorithmic instead of algorithmic. Is there a cleaner method that comes to mind?

  • 1
    Not much else, unless you want to include it in the definition of algorithmic. This would allow you to use leave your code unchanged. – Werner Oct 28 '13 at 3:27
3

Your solution is clean and clear, and I would maybe only prefer not to enclose everything in two groups, and to tweak the environment directly instead:

\let\algorithmicOLD\algorithmic
\def\algorithmic{\algorithmicOLD\algofont}

Now you can use \begin{algorithmic} directly. The advantage is that it can't happen to you that you'd use the wrong one, getting the wrong fonts.

  • Ah, good; I saw this used but thought it only applied to commands, line \textbf{}, but didn't realize \let applies to environments as well. – Up-and-coming LaTeX Mastah Oct 28 '13 at 12:06

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.