3

I have multiple different commands setup using \inputminted with different options but all are using the same language. Previously, i could feed all commands with a TeX primitive like so:

\def \usedlanguage{c}
\newcommand{\macro1}[1]{\inputminted[\breaklines,\fontsize\footnotesize]{\usedlanguage}{#1}
\newcommand{\macro2}[1]{\inputminted[\breaklines]{\usedlanguage}{#1}

etc.

Since i updated my packages recently this leaves me with the error

Error: no lexer for alias '\usedlanguage ' found

Has anyone encountered this or a similar problem and has come up with a solution? Any help would be appreciated.

Jul
  • 51
  • I can't test it here but maybe \newmintedfile[macrofirst]{\usedlanguage}{breaklines,fontsize=\footnotesize} and then \macrofirst{yourfile.c} would work. – Marijn Jan 10 '23 at 15:46
  • Hi, I have the same issue, I opened an issue at https://github.com/gpoore/minted/issues/353 – Pol Dellaiera Jan 31 '23 at 12:16

1 Answers1

2

@PolDellaiera thanks for digging into this! As pointed out by some nice guy named muzimuzhi in your issue, this is seems to be a bug introduced with minted v2.7. In this issue a workaround is proposed which seems to have worked for you, so it might work for others as well.

Since my goal was only to have a single source of truth for the language in use, i started to use \newmintedfile to define my personal macros:

\newmintedfile[codefile]{c}{breaklines}
\newcommand{\macro1}[2][firstline=1]{\codefile[#1]{#2}}
\newcommand{\macro2}[2][fontsize=\footnotesize]{\codefile[#1]{#2}}

This way, i only have to update the definition of codefile when using a different language.

Jul
  • 51