-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use a \def macro as the value for the style option #357
Comments
Since v2.6, style name is Doing fully expansion before detokenization will break cases when the style name contains active characters (probably \documentclass{article}
\usepackage{minted}
\makeatletter
% #1 default value, #2 real key, #3 user key, #4 wrapped ##1
% provide user key which actually alters real key
\newcommand{\minted@def@opt@general}[4]{%
\define@key{minted@opt@g}{#3}{%
\@namedef{minted@opt@g:#2}{#4}}
\define@key{minted@opt@g@i}{#3}{%
\@namedef{minted@opt@g@i:#2}{#4}}
\define@key{minted@opt@lang}{#3}{%
\@namedef{minted@opt@lang\minted@lang:#2}{#4}}
\define@key{minted@opt@lang@i}{#3}{%
\@namedef{minted@opt@lang\minted@lang @i:#2}{#4}}
\define@key{minted@opt@cmd}{#3}{%
\@namedef{minted@opt@cmd:#2}{#4}}
\ifstrempty{#1}{}{\@namedef{minted@opt@g:#2}{#1}}%
}
% \renewcommand{\minted@def@opt}[2][]{%
% \minted@def@opt@general{#1}{#2}{#2}{##1}}
% \renewcommand{\minted@def@opt@detok}[2][]{%
% \minted@def@opt@general{#1}{#2}{#2}{\detokenize{##1}}}
% "o" stands for "one-step expansion"
\newcommand{\minted@def@opt@detok@o}[3][]{%
\minted@def@opt@general{#1}{#2}{#3}{\detokenize\expandafter{##1}}}
% "e" stands for "fully expansion by \expanded"
\newcommand{\minted@def@opt@detok@e}[3][]{%
\minted@def@opt@general{#1}{#2}{#3}{\detokenize\expandafter{\expanded{##1}}}}
% \minted@def@opt@detok{style}
\minted@def@opt@detok@o{style}{style/expand once}
\minted@def@opt@detok@e{style}{style/expand fully}
\makeatother
\begin{document}
\begin{minted}[style=default]{latex}
\begin{align}
a + b = c
\end{align}
\end{minted}
\def\mystyle{emacs}
\begin{minted}[style/expand once=\mystyle]{latex}
\begin{align}
a + b = c
\end{align}
\end{minted}
\def\mystyle{autumn}
\def\mynestedstyle{\mystyle}
\begin{minted}[style/expand fully=\mynestedstyle]{latex}
\begin{align}
a + b = c
\end{align}
\end{minted}
\end{document} |
Thanks for the suggestion, it solved my problem. |
Ah perhaps you can leave it to the package maintainer to decide if |
I use
minted
together with thetcolorbox
package and therefore, choosing a code highlighting style, I then need to set the tcb background and frame colors appropriately.In order not to have to modify each option by hand every time I want to change the style, I decided to define a macro in such a way that only that one has to be modified.
The problem is that by passing the macro to the
style
option, I raise these errors:I add a snippet of code to better explain the situation limiting it to the use of
minted
only:Is there any solution to solve the problem?
The text was updated successfully, but these errors were encountered: