
내 전반적인 목표는 여러 복사본으로 페이지를 쉽게 채울 수 있도록 저장 상자 안에 테이블을 만드는 것입니다. 누군가 tabularx 사용을 권장했는데, 이는 일부 행에 색상을 지정하기 위해 colortbl 패키지를 사용하려고 시도하기 전까지는 잘 작동했습니다.
아래 MWE에서 다음 사항에 유의하십시오.
- 표 1: tabularx와 colortbl은 저장 상자 외부에서 함께 잘 작동합니다.
- 표 2: tabularx는 저장 상자에 저장할 때 잘 작동합니다.
- 표 3: 표 1을 저장 상자에 저장하려고 하면 '정의되지 않은 제어 순서' 오류가 발생합니다.
특히 콘솔에서 "s"(건너뛰기) 옵션을 선택하면 세 테이블이 모두 올바르게 렌더링되는 것처럼 보이는 컴파일된 문서가 생성됩니다. 따라서 문서를 조판할 수는 있지만 이 문제에 대한 "수정"이 있는지 궁금합니다.
MWE:
\documentclass{article}
\usepackage{colortbl}
\usepackage{tabularx}
\usepackage{xcolor}
\newsavebox{\tabularxInBox}
\sbox{\tabularxInBox}{
\begin{tabularx}{\textwidth}{cX}
Col 1 & Col 2\\
\hline
Row 1& No Colored Background\\
Row 2& No Colored Background\\
\end{tabularx}
}
\newsavebox{\tabularxAndColortblInBox}
\sbox{\tabularxAndColortblInBox}{
\begin{tabularx}{\textwidth}{cX}
Col 1 & Col 2\\
\hline
Row 1& No Colored Background\\
\rowcolor{lightgray}
Row 2& Colored Background\\
\end{tabularx}
}
\begin{document}
No conflict with tabularx and colortbl normally:\\
\begin{tabularx}{\textwidth}{cX}
Col 1 & Col 2\\
\hline
Row 1& No Colored Background\\
\rowcolor{lightgray}
Row 2& Colored Background\\
\end{tabularx}
\vskip 1cm
No conflict with tabularx and sbox:\\
\usebox{\tabularxInBox}
\vskip 1cm
However, using both tabularx and colortble inside an \sbox throws an error:\\
\usebox{\tabularxAndColortblInBox}
\end{document}
답변1
조판은 까지 완전히 설정되지 않았습니다 \begin{document}
. 때로는 서문의 sbox에 간단한 텍스트를 저장하는 것이 작동하지만 여기서는 그렇지 않습니다.
\documentclass{article}
\usepackage{colortbl}
\usepackage{tabularx}
\usepackage{xcolor}
\newsavebox{\tabularxInBox}
\newsavebox{\tabularxAndColortblInBox}
\begin{document}
\sbox{\tabularxInBox}{%%%dont forget eol
\begin{tabularx}{\textwidth}{cX}
Col 1 & Col 2\\
\hline
Row 1& No Colored Background\\
Row 2& No Colored Background\\
\end{tabularx}%%%dont forget eol
}
\sbox{\tabularxAndColortblInBox}{%%%dont forget eol
\begin{tabularx}{\textwidth}{cX}
Col 1 & Col 2\\
\hline
Row 1& No Colored Background\\
\rowcolor{lightgray}
Row 2& Colored Background\\
\end{tabularx}%%%dont forget eol
}
No conflict with tabularx and colortbl normally:\\
\begin{tabularx}{\textwidth}{cX}
Col 1 & Col 2\\
\hline
Row 1& No Colored Background\\
\rowcolor{lightgray}
Row 2& Colored Background\\
\end{tabularx}
\vskip 1cm
No conflict with tabularx and sbox:\\
\usebox{\tabularxInBox}
\vskip 1cm
However, using both tabularx and colortble inside an \verb|\sbox| throws an error:\\
\usebox{\tabularxAndColortblInBox}
\end{document}