2

When setting up the minted environment to use a specific fontsize, it is not correctly resize with the environment.

This is a MWE:

\documentclass{scrbook}
\usepackage[chapter]{minted}
\setminted[c++]{fontsize=\footnotesize}
%% define shortcut
\newcommand{\cd}[1]{\mintinline{c++}{#1}}
\newcommand{\cdfoot}[1]{\mintinline[fontsize=\scriptsize]{c++}{#1}}

\usepackage{scrhack}
\begin{document}

\chapter{one}

regular inline \cd{code}\footnote{footnote \cd{code} (the same size as in text)}

regular inline \cd{code} {\footnotesize \cd{code}} (no difference)

regular inline \cd{code} \cdfoot{code} (this would be expected)

\end{document}

As shown, I can work around the problem by using an extra command, but this is error-prone since the visual difference is rather small and it is easy miss incorrect usage.

3
  • Make a complete example that can be used for tests. And if possible use a font that is available on all tex systems. Feb 7, 2020 at 15:27
  • Thank for the feedback, I am reducing this to MWE that in part will have separate questions. I will return to this later or close this.
    – user188968
    Feb 7, 2020 at 17:00
  • Updated the original post.
    – user188968
    Feb 7, 2020 at 19:23

1 Answer 1

2

You seem to want that \cd uses a context depending font size, namely \footnotesize in normal size and \scriptsize in footnotes (or when \footnotesize is in force).

You're lucky, because scrbook uses 9pt size for \footnotesize, so you can easily use relsize.

\documentclass{scrbook}
\usepackage[chapter]{minted}
\usepackage{relsize}
\usepackage{scrhack}

%% define shortcut
\newcommand{\cd}{\mintinline[fontsize={\smaller}]{c++}}

\textheight=6cm % just to get a smaller picture

\begin{document}

\chapter{one}

regular inline \cd{code}\footnote{footnote \cd{code} (the same size as in text)}

regular inline \cd{code} {\footnotesize footnotesize \cd{code}}

\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 .