diff --git a/tabu.sty b/tabu.sty index e62cacf..f048000 100644 --- a/tabu.sty +++ b/tabu.sty @@ -114,7 +114,10 @@ \def\tabu@everyrowfalse{\global\let\iftabu@everyrow \iffalse} \newif \iftabu@long \newif \iftabuscantokens -\def\tabu@rescan {\tabu@verbatim \scantokens } +%% TABU-FIXED (issue #3) +%% REMOVED \tabu@verbatim +%% \def\tabu@rescan {\tabu@verbatim \scantokens } +\let\tabu@rescan \scantokens %% Utilities (for internal usage) ----------------------------------- \def\tabu@gobblespace #1 {#1} \def\tabu@gobbletoken #1#2{#1} @@ -1250,8 +1253,16 @@ \ifnum \count@>\thr@@ \let\@halignto \@empty \tabucolX@init \def\tabu@lasttry{\m@ne\p@}\fi \begingroup \iffalse{\fi \ifnum0=`}\fi - \toks@{}\def\tabu@stack{b}\iftabuscantokens \endlinechar=10 \obeyspaces \fi % - \tabu@collectbody \tabu@strategy % +%% TABU-FIXED (issue #3) +%% tabu* now collects body with a catcode 12 backslash + \toks@{}\def\tabu@stack{b}\iftabuscantokens + \endlinechar=10 \catcode`\\=12 \obeyspaces + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi % + {\tabu@collectbody@forscan\tabu@strategy{}}% + {\tabu@collectbody\tabu@strategy}% }% \tabu@setstrategy \def\tabu@savecounters{% \def\@elt ##1{\csname c@##1\endcsname\the\csname c@##1\endcsname}% @@ -1273,6 +1284,8 @@ \fi }% \tabu@Xinit %% Collecting the environment body ---------------------------------- +%% TABU-FIXED (issue #3) +%% this macro now only for non-scantokens type of body collecting \long\def\tabu@collectbody #1#2\end #3{% \edef\tabu@stack{\tabu@pushbegins #2\begin\end\expandafter\@gobble\tabu@stack}% \ifx \tabu@stack\@empty @@ -1298,6 +1311,59 @@ \def\tabu@endofcollect #1{\ifnum0=`{}\fi \expandafter\endgroup \the\toks@ #1% }% \tabu@endofcollect +%% TABU-FIXED (issue #3) +%% collects body with a catcode 12 backslash for later scantokenization +\catcode`\| \z@ +\catcode`\\ 12 +|long|def|tabu@collectbody@forscan #1#2#3\end{% + |def|tabu@collectbody@forscan@next{|tabu@collectbody@forscan{#1}}% + |toks|tw@{#2#3}% + |futurelet|tabu@temp@token|tabu@collectbody@forscan@a +}% \tabu@collectbody@forscan +|def|tabu@collectbody@forscan@a{% + |ifcat|noexpand|tabu@temp@token e% + |expandafter|tabu@collectbody@forscan@aa + |else + |expandafter|tabu@collectbody@forscan@b + |fi +}% \tabu@collectbody@forscan@a +|def|tabu@collectbody@forscan@aa #1{% + |expandafter|tabu@collectbody@forscan@next|expandafter{|the|toks|tw@\end#1}% +}% \tabu@collectbody@forscan@aa +|def|tabu@collectbody@forscan@b #1{% + |edef|tabu@stack{|expandafter|tabu@pushbegins@forscan + |the|toks|tw@\begin|relax|expandafter|@gobble|tabu@stack}% + |ifx |tabu@stack|@empty + |expandafter|tabu@collectbody@forscan@end + |else + |expandafter|tabu@collectbody@forscan@continue + |fi + {#1}% +}% \tabu@collectbody@forscan@b +|def|tabu@collectbody@forscan@end #1{% + |edef|tabu@@temp{|tabu@thebody{|the|toks@|the|toks|tw@}}% + |toks@|expandafter{|tabu@@temp + |def|tabu@end@envir{|end{#1}}% + |iftabu@long |def|tabu@endenvir {|end{#1}|tabu@gobbleX}% + |else |def|tabu@endenvir {|let|endarray |@empty + |end{#1}|tabu@gobbleX}% + |fi}% + |let|tabu@collectbody@forscan|tabu@endofcollect + |tabu@collectbody@forscan@next +}% \tabu@collectbody@forscan@end +|def|tabu@collectbody@forscan@continue #1{% + |edef|tabu@@temp{|the|toks@|the|toks|tw@\end}% + |def|tabu@temp{#1}% + |ifx |tabu@temp|@empty |toks@|expandafter{|tabu@@temp}% + |else |ifx|tabu@temp|tabu@@spxiii |toks@|expandafter{|tabu@@temp#1}% + |else |ifx|tabu@temp|tabu@X |toks@|expandafter{|tabu@@temp#1}% + |else |toks@|expandafter{|tabu@@temp{#1}}% + |fi|fi|fi + |tabu@collectbody@forscan@next{}% +}% \tabu@collectbody@forscan@continue +|long|def|tabu@pushbegins@forscan #1\begin#2{|ifx|relax#2|else b|expandafter|tabu@pushbegins@forscan|fi}% +|catcode`|\ |z@ +\catcode`\| 12 %% The trials: switching between strategies ------------------------- \def\tabu@strategy {\relax % stops \count@ assignment ! \ifcase\count@ % case 0 = print with vertical adjustment (outer is finished) @@ -2040,34 +2106,9 @@ \fi\fi }% \tabu@printdecimal %% Verbatim inside X columns ---------------------------------------- -\def\tabu@verbatim{% - \let\verb \tabu@verb - \let\FV@DefineCheckEnd \tabu@FV@DefineCheckEnd -}% \tabu@verbatim -\let\tabu@ltx@verb \verb -\def\tabu@verb{\@ifstar {\tabu@ltx@verb*} \tabu@ltx@verb} -\def\tabu@fancyvrb {% - \def\tabu@FV@DefineCheckEnd ##1{% - \def\tabu@FV@DefineCheckEnd{% - ##1% - \let\FV@CheckEnd \tabu@FV@CheckEnd - \let\FV@@CheckEnd \tabu@FV@@CheckEnd - \let\FV@@@CheckEnd \tabu@FV@@@CheckEnd - \edef\FV@EndScanning{% - \def\noexpand\next{\noexpand\end{\FV@EnvironName}}% - \global\let\noexpand\FV@EnvironName\relax - \noexpand\next}% - \xdef\FV@EnvironName{\detokenize\expandafter{\FV@EnvironName}}}% - }\expandafter\tabu@FV@DefineCheckEnd\expandafter{\FV@DefineCheckEnd} -}% \tabu@fancyvrb -\def\tabu@FV@CheckEnd #1{\expandafter\FV@@CheckEnd \detokenize{#1\end{}}\@nil} -\edef\tabu@FV@@@CheckEnd {\detokenize{\end{}}} -\begingroup -\catcode`\[1 \catcode`\]2 -\@makeother\{ \@makeother\} - \edef\x[\endgroup - \def\noexpand\tabu@FV@@CheckEnd ##1\detokenize[\end{]##2\detokenize[}]##3% - ]\x \@nil{\def\@tempa{#2}\def\@tempb{#3}} +%% TABU-FIXED (issue #3) +%% REMOVED \tabu@verbatim, \tabu@verb, \tabu@FV@DefineCheckEnd, ... +%% REMOVED \tabu@fancyvrb, \tabu@FV@CheckEnd, etc... \def\tabu@FV@ListProcessLine #1{% \hbox {%to \hsize{% \kern\leftmargin @@ -2540,8 +2581,10 @@ ifHy@hyperfootnotes\else iffalse\fi\endcsname \let\tabu@footnotetext \tabu@Hy@ftntext \let\tabu@xfootnote \tabu@Hy@xfootnote \fi - \ifdefined\FV@DefineCheckEnd% - \tabu@fancyvrb \fi +%% TABU-FIXED (issue #3) +%% REMOVED \tabu@fancyvrb +%% \ifdefined\FV@DefineCheckEnd% +%% \tabu@fancyvrb \fi \ifdefined\color % \let\tabu@color \color \def\tabu@leavevmodecolor ##1{% diff --git a/testfiles/t003.lvt b/testfiles/t003.lvt new file mode 100644 index 0000000..0350bd3 --- /dev/null +++ b/testfiles/t003.lvt @@ -0,0 +1,40 @@ +\documentclass{article} +\usepackage{fancyvrb} +\usepackage{tabu} +\newenvironment{yyyyyy}{START}{END} +\input{regression-test} +\begin{document} + +\START +\begin{tabu*}to\linewidth{|XX|} +% if }{ in the short verb then already not working in tabu 2.09 +A short verb: \verb|$&\~{}#|&\\ +\begin{Verbatim}[commandchars={\\\{\}}] +And \textit{this} is a \textbf{\textrm{complete}} +Verbatim environment $&~\textbraceleft\textbraceright +{\footnotesize this is smaller} +\textit{spaces are ok I hope} +\normalfont\yyyyyy\begin{yyyyyy}hello\end{yyyyyy}hello\endyyyyyy +\def\foo{foo}\meaning\foo +\meaning\foo (ok as each line is\ +scoped by fancyvrb) # +\begin{Large}AA{\footnotesize{}BB}CC\end{Large} +\begin{Large}AA\begin{footnotesize}BB\end{footnotesize}CC\end{Large} +\end{Verbatim} +& +\begin{Verbatim} +And \textit{this} is a \textbf{\textrm{complete}} +Verbatim environment $&~\textbraceleft\textbraceright +{\footnotesize this is smaller} +\textit{spaces are ok I hope} +\normalfont\yyyyyy\begin{yyyyyy}hello\end{yyyyyy}hello\endyyyyyy +\def\foo{foo}\meaning\foo +\meaning\foo (ok as each line is\ +scoped by fancyvrb) # +\begin{Large}AA{\footnotesize{}BB}CC\end{Large} +\begin{Large}AA\begin{footnotesize}BB\end{footnotesize}CC\end{Large} +\end{Verbatim} +\\ +\end{tabu*} + +\end{document}