3

I have the following code for a new environment definition:

\newenvironment{VList}
{
\makeatletter
\begin{tcblisting}
\bgroup
  enhanced,oversize,lower separated=false,
  colframe=red!50!black,colback=yellow!10!white,
  interior style=\bgroup 
  top color=yellow!5!white,bottom color=yellow!20!white
  \egroup ,
  listing side comment,sidebyside gap=5mm,
  listing options=\bgroup 
  style=tcblatex,texcsstyle=*\color\bgroup
  red!70!black\egroup
  \egroup,
\egroup\makeatother
}
{
\makeatletter\end{tcblisting}\makeatother
}

However, when I type the following code for making a frame in beamerLaTeX complains:

\begin{frame}[fragile]{Sample GNUPLOT code}{A {\tt gnuplot} and \LaTeX{} combo}
Start {\tt gnuplot}, and write the following codes:
\begin{VList}
set term tikz color solid size 4in,3in
set output "sin.tex"
set xr [-2*pi:2*pi]
plot sin(x) with lines
exit
\end{VList}
\end{frame}
1
  • You can't use \bgroup and \egroup in that context.
    – egreg
    Jan 11, 2015 at 11:27

1 Answer 1

4

First, there seems to be some trouble with the \bgroup / \egroup pairs. For reasons I cannot see in the moment, they behave differently in the verbatim context. After replacing them by { and }, there is a 'normal' error which is resolved by replacing \begin{tcblisting} and \end{tcblisting} by the corresponding macros. The following compiles:

\documentclass{beamer}

\usepackage[most]{tcolorbox}

\newenvironment{VList}
{\tcblisting{
  enhanced,oversize,lower separated=false,
  colframe=red!50!black,colback=yellow!10!white,
  interior style={top color=yellow!5!white,bottom color=yellow!20!white},
  listing side comment,sidebyside gap=5mm,
  listing options={style=tcblatex,texcsstyle=*\color{red!70!black}}%
}
}{%
\endtcblisting%
}

\begin{document}

\begin{frame}[fragile]{Sample GNUPLOT code}{A {\tt gnuplot} and \LaTeX{} combo}
Start {\tt gnuplot}, and write the following codes:
\begin{VList}
set term tikz color solid size 4in,3in
set output "sin.tex"
set xr [-2*pi:2*pi]
plot sin(x) with lines
exit
\end{VList}
\end{frame}

\end{document}

But, I would recommend to use the environment generation procedure using \newtcblisting which handles everything:

\documentclass{beamer}

\usepackage[most]{tcolorbox}

\newtcblisting{VList}{
  enhanced,oversize,lower separated=false,
  colframe=red!50!black,colback=yellow!10!white,
  interior style={top color=yellow!5!white,bottom color=yellow!20!white},
  listing side comment,sidebyside gap=5mm,
  listing options={style=tcblatex,texcsstyle=*\color{red!70!black}}%
}

\begin{document}

\begin{frame}[fragile]{Sample GNUPLOT code}{A {\tt gnuplot} and \LaTeX{} combo}
Start {\tt gnuplot}, and write the following codes:
\begin{VList}
set term tikz color solid size 4in,3in
set output "sin.tex"
set xr [-2*pi:2*pi]
plot sin(x) with lines
exit
\end{VList}
\end{frame}

\end{document}
2
  • \color\bgroup red\egroup is illegal anywhere. The argument to \color would be \bgroup (technically the argument is to \@declaredcolor, but it's the same).
    – egreg
    Jan 11, 2015 at 11:29
  • @egreg Thanks for helping to explain this :-) Also, some more \bgroup / \egroup pairs have to be illegal in the original code. Jan 11, 2015 at 11:32

You must log in to answer this question.

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