1

I want to use the tabstackengine package in a tcblisting environment, but get a lot of error messages. How can I make this work?

\documentclass{article}
\usepackage{amsmath}
\usepackage{tabstackengine}

\usepackage{listings}
\usepackage[most]{tcolorbox}

\stackMath
\setstacktabbedgap{0.5em}
\setstackTAB{ }

\begin{document}



\begin{tcblisting}{title=System of linear equations,text side listing}
  \[
\tabbedCenterstack[r]{
  \text{I:}     -2x +  y + 3z = 10 + x \\ 
  \text{II' = I + II:}     x +  y +  z =  6 + 2z\\
  \text{III:}     3 + 3y + 2z = y - 3z 
}\]
\end{tcblisting}

\end{document}

Error messages:

./tabbedstacked.listing:6: Undefined control sequence.
\\->\let \reserved@e 
                     \relax \let \reserved@f \relax \@ifstar {\let \reserved...l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\\->\let \reserved@e \relax \let \reserved@f 
                                             \relax \@ifstar {\let \reserved...l.6 }
     \]
./tabbedstacked.listing:6: Use of \\tabbedCenterstack doesn't match its definition.
\new@ifnextchar ...served@d = #1\def \reserved@a {
                                                  #2}\def \reserved@b {#3}\f...l.6 }
     \]
./tabbedstacked.listing:6: Use of \\tabbedCenterstack doesn't match its definition.
<argument> \def \reserved@a *
                             {\let \reserved@e \vadjust \let \reserved@f \no...l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
<argument> \def \reserved@a *{\let \reserved@e 
                                               \vadjust \let \reserved@f \no...l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
<argument> ...eserved@e \vadjust \let \reserved@f 
                                                  \nobreak \@xnewline }\rese...l.6 }
     \]
./tabbedstacked.listing:6: Use of \\tabbedCenterstack doesn't match its definition.
\@ifnextchar ... \reserved@d =#1\def \reserved@a {
                                                  #2}\def \reserved@b {#3}\f...l.6 }
     \]
./tabbedstacked.listing:6: Use of \@newline doesn't match its definition.
\@ifnextchar ...eserved@d =#1\def \reserved@a {#2}
                                                  \def \reserved@b {#3}\futu...l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\@calc@post@scan ...st@scan \else \def \calc@next 
                                                  {\calc@error #1}\fi \fi \f...l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\@calc@post@scan ...fi \fi \fi \fi \fi \calc@next 

l.6 }
     \]
./tabbedstacked.listing:6: Argument of \@secondoftwo has an extra }.
<inserted text> 
                \par 
l.6 }
     \]
Runaway argument?
./tabbedstacked.listing:6: Paragraph ended before \@secondoftwo was complete.
<to be read again> 
                   \par 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \csname\endcsname 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \csname\endcsname 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \MessageBreak 
l.6 }
     \]
./tabbedstacked.listing:6: Argument of \@processROW has an extra }.
<inserted text> 
                \par 
l.6 }
     \]
Runaway argument?
||\expandafter \ifstrempty \expandafter {\@postSEP }{\toggletrue {@do\ETC.
./tabbedstacked.listing:6: Paragraph ended before \@processROW was complete.
<to be read again> 
                   \par 
l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\@calc@post@scan ...st@scan \else \def \calc@next 
                                                  {\calc@error #1}\fi \fi \f...l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\@calc@post@scan ...fi \fi \fi \fi \fi \calc@next 

l.6 }
     \]
./tabbedstacked.listing:6: Argument of \@firstoftwo has an extra }.
<inserted text> 
                \par 
l.6 }
     \]
Runaway argument?
./tabbedstacked.listing:6: Paragraph ended before \@firstoftwo was complete.
<to be read again> 
                   \par 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \csname\endcsname 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \csname\endcsname 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \MessageBreak 
l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\@calc@post@scan ...st@scan \else \def \calc@next 
                                                  {\calc@error #1}\fi \fi \f...l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\@calc@post@scan ...fi \fi \fi \fi \fi \calc@next 

l.6 }
     \]
./tabbedstacked.listing:6: Argument of \@secondoftwo has an extra }.
<inserted text> 
                \par 
l.6 }
     \]
Runaway argument?
./tabbedstacked.listing:6: Paragraph ended before \@secondoftwo was complete.
<to be read again> 
                   \par 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \csname\endcsname 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \csname\endcsname 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \MessageBreak 
l.6 }
     \]
./tabbedstacked.listing:6: Argument of \@processTABrow has an extra }.
<inserted text> 
                \par 
l.6 }
     \]
Runaway argument?
||\global \csedef {TABX\row@ID X\roman {TABcellindex@}}{\expandonce \@preTAB \ETC.
./tabbedstacked.listing:6: Paragraph ended before \@processTABrow was complete.
<to be read again> 
                   \par 
l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\@calc@post@scan ...st@scan \else \def \calc@next 
                                                  {\calc@error #1}\fi \fi \f...l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\@calc@post@scan ...fi \fi \fi \fi \fi \calc@next 

l.6 }
     \]
./tabbedstacked.listing:6: Argument of \@firstoftwo has an extra }.
<inserted text> 
                \par 
l.6 }
     \]
Runaway argument?
./tabbedstacked.listing:6: Paragraph ended before \@firstoftwo was complete.
<to be read again> 
                   \par 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \csname\endcsname 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \csname\endcsname 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \MessageBreak 
l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\@calc@post@scan ...st@scan \else \def \calc@next 
                                                  {\calc@error #1}\fi \fi \f...l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\@calc@post@scan ...fi \fi \fi \fi \fi \calc@next 

l.6 }
     \]
./tabbedstacked.listing:6: Argument of \@secondoftwo has an extra }.
<inserted text> 
                \par 
l.6 }
     \]
Runaway argument?
./tabbedstacked.listing:6: Paragraph ended before \@secondoftwo was complete.
<to be read again> 
                   \par 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \csname\endcsname 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \csname\endcsname 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \MessageBreak 
l.6 }
     \]
./tabbedstacked.listing:6: Argument of \@processTABrow has an extra }.
<inserted text> 
                \par 
l.6 }
     \]
Runaway argument?
||\global \csedef {TABX\row@ID X\roman {TABcellindex@}}{\expandonce \@preTAB \ETC.
./tabbedstacked.listing:6: Paragraph ended before \@processTABrow was complete.
<to be read again> 
                   \par 
l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\@calc@post@scan ...st@scan \else \def \calc@next 
                                                  {\calc@error #1}\fi \fi \f...l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\@calc@post@scan ...fi \fi \fi \fi \fi \calc@next 

l.6 }
     \]
./tabbedstacked.listing:6: Argument of \@firstoftwo has an extra }.
<inserted text> 
                \par 
l.6 }
     \]
Runaway argument?
./tabbedstacked.listing:6: Paragraph ended before \@firstoftwo was complete.
<to be read again> 
                   \par 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \csname\endcsname 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \csname\endcsname 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \MessageBreak 
l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\@calc@post@scan ...st@scan \else \def \calc@next 
                                                  {\calc@error #1}\fi \fi \f...l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\@calc@post@scan ...fi \fi \fi \fi \fi \calc@next 

l.6 }
     \]
./tabbedstacked.listing:6: Argument of \@firstoftwo has an extra }.
<inserted text> 
                \par 
l.6 }
     \]
Runaway argument?
./tabbedstacked.listing:6: Paragraph ended before \@firstoftwo was complete.
<to be read again> 
                   \par 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \csname\endcsname 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \csname\endcsname 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \MessageBreak 
l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\@calc@post@scan ...st@scan \else \def \calc@next 
                                                  {\calc@error #1}\fi \fi \f...l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\@calc@post@scan ...fi \fi \fi \fi \fi \calc@next 

l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\set@tabularcellalignment ...ef \tabular@settings 
                                                  {#1.}\whileboolexpr {test ...l.6 }
     \]
./tabbedstacked.listing:6: Argument of \@firstoftwo has an extra }.
<inserted text> 
                \par 
l.6 }
     \]
Runaway argument?
./tabbedstacked.listing:6: Paragraph ended before \@firstoftwo was complete.
<to be read again> 
                   \par 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \csname\endcsname 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \csname\endcsname 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \MessageBreak 
l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\set@tabularcellalignment ...ef \tabular@settings 
                                                  {\expandafter \@gobble \ta...l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\set@tabularcellalignment ...le \tabular@settings 
                                                  .}}\expandafter \@getnextT...l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\set@tabularcellalignment ...ar \tabular@settings 
                                                  \\\if l\@nextTABchar \edef...l.6 }
     \]
./tabbedstacked.listing:6: Argument of \@getnextTABchar has an extra }.
<inserted text> 
                \par 
l.6 }
     \]
Runaway argument?
\if l\@nextTABchar \edef \stackalignment {l}\else \if r\@nextTABchar \ETC.
./tabbedstacked.listing:6: Paragraph ended before \@getnextTABchar was complete.
<to be read again> 
                   \par 
l.6 }
     \]
./tabbedstacked.listing:6: Argument of \@secondoftwo has an extra }.
<inserted text> 
                \par 
l.6 }
     \]
Runaway argument?
./tabbedstacked.listing:6: Paragraph ended before \@secondoftwo was complete.
<to be read again> 
                   \par 
l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\@calc@post@scan ...st@scan \else \def \calc@next 
                                                  {\calc@error #1}\fi \fi \f...l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\@calc@post@scan ...fi \fi \fi \fi \fi \calc@next 

l.6 }
     \]
./tabbedstacked.listing:6: Argument of \@firstoftwo has an extra }.
<inserted text> 
                \par 
l.6 }
     \]
Runaway argument?
./tabbedstacked.listing:6: Paragraph ended before \@firstoftwo was complete.
<to be read again> 
                   \par 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \csname\endcsname 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \csname\endcsname 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \MessageBreak 
l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\\->\let \reserved@e 
                     \relax \let \reserved@f \relax \@ifstar {\let \reserved...l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\\->\let \reserved@e \relax \let \reserved@f 
                                             \relax \@ifstar {\let \reserved...l.6 }
     \]
./tabbedstacked.listing:6: Use of \\tabbedCenterstack doesn't match its definition.
\new@ifnextchar ...served@d = #1\def \reserved@a {
                                                  #2}\def \reserved@b {#3}\f...l.6 }
     \]
./tabbedstacked.listing:6: Use of \\tabbedCenterstack doesn't match its definition.
<argument> \def \reserved@a *
                             {\let \reserved@e \vadjust \let \reserved@f \no...l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
<argument> \def \reserved@a *{\let \reserved@e 
                                               \vadjust \let \reserved@f \no...l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
<argument> ...eserved@e \vadjust \let \reserved@f 
                                                  \nobreak \@xnewline }\rese...l.6 }
     \]
./tabbedstacked.listing:6: Use of \\tabbedCenterstack doesn't match its definition.
\@ifnextchar ... \reserved@d =#1\def \reserved@a {
                                                  #2}\def \reserved@b {#3}\f...l.6 }
     \]
./tabbedstacked.listing:6: Use of \@newline doesn't match its definition.
\@ifnextchar ...eserved@d =#1\def \reserved@a {#2}
                                                  \def \reserved@b {#3}\futu...l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\@calc@post@scan ...st@scan \else \def \calc@next 
                                                  {\calc@error #1}\fi \fi \f...l.6 }
     \]
./tabbedstacked.listing:6: Undefined control sequence.
\@calc@post@scan ...fi \fi \fi \fi \fi \calc@next 

l.6 }
     \]
./tabbedstacked.listing:6: Argument of \@secondoftwo has an extra }.
<inserted text> 
                \par 
l.6 }
     \]
Runaway argument?
./tabbedstacked.listing:6: Paragraph ended before \@secondoftwo was complete.
<to be read again> 
                   \par 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \csname\endcsname 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \csname\endcsname 
l.6 }
     \]
./tabbedstacked.listing:6: Missing \endcsname inserted.
<to be read again> 
                   \MessageBreak 
l.6 }
     \]
(That makes 100 errors; please try again.)
./tabbedstacked.listing:6:  ==> Fatal error occurred, no output PDF file produced!
Transcript written on tabbedstacked.log.
Latexmk: Errors, so I did not complete making targets
Collected error summary (may duplicate other messages):
  pdflatex: Command for 'pdflatex' gave return code 256
Latexmk: Use the -f option to force complete processing,
 unless error was exceeding maximum runs of latex/pdflatex.

TeX Output exited abnormally with code 12 at Mon Aug 29 23:51:19
  • 1
    The current version of tabstackengine , 2016/11/30 (V2.01), is more robust and works OK with the original code of the OP. – Steven B. Segletes Oct 6 '17 at 14:08
3

tcblisting (like e.g. minipage) calls internally \@parboxrestore, which sets \\ to \@normalcr. Unlike \\ \@normalcr is not robust and so the code of stackengine breaks. Making \@normalcr robust avoids the problem.

\documentclass{article}
\usepackage{amsmath}

\usepackage{tabstackengine}

\usepackage{listings}
\usepackage[most]{tcolorbox}

\stackMath
\setstacktabbedgap{0.5em}
\setstackTAB{ }

\makeatletter
\robustify{\@normalcr} %globally robust
%avoids error but wrong output:
%\def\@parboxrestore{\@arrayparboxrestore\def\\{\protect\@normalcr}}
\makeatother

\begin{document}

\begin{tcblisting}{title=System of linear equations,text side listing}
  \[
\tabbedCenterstack[r]{
  \text{I:}     -2x +  y + 3z = 10 + x \\
  \text{II' = I + II:}     x +  y +  z =  6 + 2z\\
  \text{III:}     3 + 3y + 2z = y - 3z
}
\]
\end{tcblisting}

\end{document}

I don't know why \@normalcr wasn't robust from the start and it is possible that a redefinition can have side effects. In this case stackengine will have to make it robust locally or change the code that scans for the EOL.

  • The redefinition of \@parboxrestore doesn't work; with \robustify the result is wrong anyway. – egreg Aug 30 '16 at 10:19
  • @egreg You are right redefining \@parboxrestrore not enough -- I only looked at the errors. But what you mean regarding \robustify? That the lines are too long? – Ulrike Fischer Aug 30 '16 at 10:32
  • Yes, the math display overlaps the code part. The \robustify method, which applies \protected, should not have any particular side effect, because \protected macros obey \expandafter (which is not the case for the legacy protection mechanism in LaTeX2e that uses \protect). A \protected macro is not expanded only in \edef or \write contexts. – egreg Aug 30 '16 at 10:33
  • @egreg: The width is a tcolorbox question, one need to set e.g. the lefthand width (or move the code above the output). – Ulrike Fischer Aug 30 '16 at 10:37
  • Two observations:1) to avoid conflicting EOL characters, stackengine has \setstackEOL{\cr} for example, to change the stacking EOL notation; and 2) a % after the opening { of the \tabbedCenterstack will help resolve the alignment. – Steven B. Segletes Aug 30 '16 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.