7

escapeinside=|| usually works but not inside what for my programming language (SAS) is a string:

\documentclass[a4paper,12pt]{book}
\usepackage{minted}
\usemintedstyle{vs}
\newcommand{\sasinline}[1]{\mintinline{sas}{#1}}
\newenvironment{sas}{\VerbatimEnvironment
  \begin{minted}[escapeinside=||]{sas}}
 {\end{minted}}

\begin{document} 

Is it possible to write \emph{percorso fisico} in italics here?
\begin{sas}
libname <|\emph{nome logico}|> '<|\emph{percorso fisico}|>' <|\emph{eventuali opzioni}|>;
\end{sas}

Leaving this as is:
\begin{sas}
libname corso '/projects/corsosas';
\end{sas}

\end{document}

enter image description here

4
  • From the minted manual: “Escaping does not work inside strings and comments”
    – egreg
    Aug 2, 2017 at 16:58
  • @egreg ... but David found a solution, anyway :)
    – CarLaTeX
    Aug 2, 2017 at 18:05
  • 2
    You can improve the solution by doing \newcommand{\metastring}[1]{\PYG{l+s}{\PYGZsq{}<}\PYG{l+s}{\emph{#1}}\PYG{l+s}{>\PYGZsq{}}} and using |\metastring{percorso fisico}|.
    – egreg
    Aug 3, 2017 at 10:14
  • @egreg Already done, of course! The only difference is that I called it \sasstringemph :)
    – CarLaTeX
    Aug 3, 2017 at 10:28

1 Answer 1

8

An answer I know you will want to accept:

enter image description here

\documentclass[a4paper,12pt]{book}
\usepackage{minted}
\usemintedstyle{vs}
\newcommand{\sasinline}[1]{\mintinline{sas}{#1}}
\newenvironment{sas}{\VerbatimEnvironment
  \begin{minted}[escapeinside=||]{sas}}
 {\end{minted}}

\begin{document} 

Is it possible to write \emph{percorso fisico} in italics here?
\begin{sas}
libname <|\emph{nome logico}|> |\PYG{l+s}{\PYGZsq{}<}\PYG{l+s}{\emph{pineapple pizza}}\PYG{l+s}{>\PYGZsq{}}| <|\emph{eventuali opzioni}|>;
\end{sas}

Leaving this as is:
\begin{sas}
libname corso '/projects/corsosas';
\end{sas}

\end{document}
2
  • "Pineapple pizza" will become the new "ducks" for vote-attraction! :-)
    – CarLaTeX
    Aug 2, 2017 at 16:02
  • 4
    It is important to note that escapeinside will also appear to not work if the document is in draft mode
    – DavisDude
    Feb 6, 2020 at 16:12

You must log in to answer this question.

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