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

CarLaTeX
  • 62,716
  • From the minted manual: “Escaping does not work inside strings and comments” – egreg Aug 02 '17 at 16:58
  • @egreg ... but David found a solution, anyway :) – CarLaTeX Aug 02 '17 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 03 '17 at 10:14
  • @egreg Already done, of course! The only difference is that I called it \sasstringemph :) – CarLaTeX Aug 03 '17 at 10:28

1 Answers1

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}
David Carlisle
  • 757,742