2

I have side paragraphs in italics and I am using typewriter fonts in the main text to refer to code elements. I want to use the same font in my side paragraphs because it should be clear that it is the same concept and it gets messy with too many fonts. However I keep getting the italic monospace font. How can I get the non italic monospaced font? I have tried so many hacks but nothing seems to work...

\documentclass{memoir}
\usepackage[lining]{ebgaramond}
\renewcommand*{\sideparfont}{\footnotesize\itshape}
\begin{document}
\sidepar{Lorem \texttt{foo-bar} ipsum}
Lorem ispum cit \texttt{foo-bar} dolor.
\end{document}

enter image description here

2 Answers 2

2

there are two possible methods -- using \textup (which takes an argument, thus requiring another set of braces) or using \upshape (which can be included as the first element inside the \texttt group):

\documentclass{memoir}
\usepackage[lining]{ebgaramond}
\renewcommand*{\sideparfont}{\footnotesize\itshape}
\begin{document}
\sidepar{Lorem \textup{\texttt{foo-bar}} ipsum}
Lorem ispum cit \texttt{foo-bar} dolor.

\sidepar{Lorem \texttt{\upshape foo-bar} ipsum}
Lorem ispum cit \texttt{foo-bar} dolor.
\end{document}

output of example code

1

You possibly want monospaced text to always appear upright; just redefine \texttt to do it: the usual definition is

\DeclareTextFontCommand{\texttt}{\ttfamily}

and we just need to add \upshape.

\documentclass{memoir}
\usepackage[lining]{ebgaramond}

\renewcommand*{\sideparfont}{\footnotesize\itshape}
\DeclareTextFontCommand{\texttt}{\ttfamily\upshape}

\begin{document}

\sidepar{Lorem \texttt{foo-bar} ipsum}
Lorem ispum cit \texttt{foo-bar} dolor.

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .