1

In the MWE below, where $default^{ok}$ is typeset by LaTeX, I define escaping characters. Is it possible to modify this setting every time I would need to use pipelines in my code ? Can I simply turn off the escaping ?

This will save me to type |\pipeline| in the code with \newcommand\pipeline{|} defined in the LaTeX file.

One easy solution would be to define an environment without escaping characters but if I could use one single environment, this would be great.

Maybe pgfkeys can do the job but I am still reading the section about pgfkeys in the book "LaTeX and friends".

\documentclass[12pt,a4paper]{article}

\usepackage[many, minted]{tcolorbox}
\usetikzlibrary{tikzmark, calc, fit}

\makeatletter
% Source: https://tex.stackexchange.com/a/124688/6880
\newcommand{\mynewminted}[3]{%
    \newminted[#1]{#2}{#3}%
    \tcbset{myminted/#1/.style = {
        minted language = #2, 
        minted options  = {#3}
    }}
}

\newcommand{\create@new@coding@env@title}[1]{%
    \mynewminted{for-coding-#1}{python}{escapeinside=||}
    \newtcblisting[]{coding-#1}[2][1]{%
        listing only,
        width = ##1\linewidth,
        title = ##2,
        myminted/for-coding-python,
    }
}

\create@new@coding@env@title{python}

\makeatother

\begin{document}

\begin{coding-python}{Basic loop Python}
def oneloop(n):            
    for i in range(n):  |$default^{ok}$|
        print(i**2)

oneloop(10)
\end{coding-python}

\end{document}
projetmbc
  • 13,315

0 Answers0