포스트앰블의 셀이 있는 \newenvironment 내부에는 '금기'를 포함할 수 없습니다.

포스트앰블의 셀이 있는 \newenvironment 내부에는 '금기'를 포함할 수 없습니다.

tabu환경의 새로운 정의에 내부 를 포함시키려고 하는데 enddef새 환경의 포스트앰블( )에 tabu의 내용이 포함되어 있으므로 셀이 실패합니다. 또는 작동 tabular합니다 tabular*. 오류는 다음과 같습니다

! Missing number, treated as zero. \[email protected]

MWE:

\documentclass{article}
\usepackage{tabu}
\newenvironment{testt}
{\begin{tabu} to \textwidth{cccc}
 11 & 12 & 13 & 14 \\
 21 & 22 & 23 & 24 \\}
{
 41 & 42 & 43 & 44
\end{tabu}
}

\begin{document}

\begin{testt}
 31 & 32 & 33 & 34 \\
\end{testt}
\end{document}

이 문제를 해결하는 방법은 무엇입니까?

답변1

패키지를 사용해 보세요 environ. 이 패키지는 \BODY중괄호 불일치 및 이 질문에서 발생한 문제와 같은 문제를 방지하기 위해 매개변수의 위치를 ​​마크업하는 데 사용됩니다.

그것을 참조하십시오문서.

\documentclass{article}
\usepackage{tabu}
\usepackage{environ}
\NewEnviron{testt}
{\begin{tabu} to \textwidth{cccc}
 11 & 12 & 13 & 14 \\
 21 & 22 & 23 & 24 \\
 \BODY
 41 & 42 & 43 & 44
\end{tabu}
}

\begin{document}

\begin{testt}
 31 & 32 & 33 & 34 \\
\end{testt}

\end{document}

답변2

패키지 tabu는 내부적으로

\tabu@collectbody#1#2\end

조판하기 전에 표의 모든 내용을 수집합니다. 테이블을 '숨기면' 제대로 작동하지 않습니다. \end{tabu}예를 들어 다음과 같이 숨기면 작동합니다.

\documentclass{article}
\usepackage{tabu}
\newenvironment{testt}
{\begin{tabu} to \textwidth{cccc}
 11 & 12 & 13 & 14 \\
 21 & 22 & 23 & 24 \\}
{
\end{tabu}
}

\begin{document}

\begin{testt}
 31 & 32 & 33 & 34 \\
 41 & 42 & 43 & 44
\end{testt}
\end{document}

여전히 모든 테이블을 올바르게 잡고 있습니다.

셀 내부에서 사용하면 뭔가 잘못되었음을 알 수 있습니다 \showthe\currentgrouplevel. 모든 '작동' 사례에는 그룹 수준 14가 있고 '잘못된' 사례에는 그룹 수준 8이 있습니다.

egreg가 말했듯이 이것은 틀림없이 의 버그 tabu이거나 적어도 문서화되어야 하는 '기능'입니다. 해결 방법에 대한 조언을 얻으려면 귀하가 어떤 영향을 받고 있는지 알아야 하며 그런 다음 대체 접근 방식을 제안할 수 있습니다. 제 생각에는 그것이 새로운 질문으로 가장 좋을 것 같습니다.

답변3

패키지 로 시도해 볼 수도 있습니다 collect. 참고하세요: 둘 다 사용해 본 적이 없고 collect이것이 tabu실행 가능하고 강력한 방법인지 전문적으로 평가할 수 없습니다.

\documentclass{article}
\usepackage{tabu}
\usepackage{collect}

\definecollection{rescuetabu}

\makeatletter
\newenvironment{testt}
{\@nameuse{collect*}{rescuetabu}
 {\begin{tabu} to \textwidth{cccc}
 11 & 12 & 13 & 14 \\
 21 & 22 & 23 & 24 \\ }
 {41 & 42 & 43 & 44 \\ \end{tabu}}{}{}}
{\@nameuse{endcollect*}}
\makeatother

\begin{document}

\texttt{normal tabu}

\begin{tabu} to \textwidth{cccc}
 11 & 12 & 13 & 14 \\
 21 & 22 & 23 & 24 \\ 
 31 & 32 & 33 & 34 \\
\end{tabu}

\hrule\medskip
\texttt{rescued tabus}

\begin{testt}
 31 & 32 & 33 & 34 \\
\end{testt}

\bigskip

\begin{testt}
 51 & 52 & 53 & 54 \\
 61 & 62 & 63 & 64 \\
\end{testt}
\hrule

\end{document}

구출된 금기

관련 정보