
첫째, 꽤 구체적인 내용을 원하기 때문에 다소 긴 서문이 있는 LyX를 사용하고 있지만 서문의 거의 모든 코드는 몇 가지 수정을 거쳐 'Net에서 잘라내어 붙여넣었습니다. 저는 TeX 전문가는 아니지만 TeX 전문가가 필요합니다!
나는 거의 항상 Float Table 환경에서 Zebra 테이블을 사용합니다. 나는 또한 몇 가지 부동 그림 환경을 가지고 있으며 실제로는 테이블이 아니기 때문에 얼룩말 효과를 끄고 싶습니다. 설명하기가 어렵고 예를 첨부할 수 없는 것 같습니다.
내가 원하는 것은 조건부(ERT는 괜찮지만 서문에 맞출 수 있다면 더 좋습니다)는 Float: Figure 환경에 있을 때 Zebra 테이블을 끄는 것입니다.
다음은 Zebra 테이블(및 기타 테이블 형식)에 사용하는 것입니다.
%
% Zebra Tables w/footnotes
%
\let\mytoprule\toprule
\renewcommand{\toprule}{\mytoprule[2pt]}
\let\mybottomrule\bottomrule
\renewcommand{\bottomrule}{\mybottomrule[2pt]}
\let\mymidrule\midrule
\renewcommand{\midrule}{\mymidrule[1pt]}
\let\tabulary\tabular
\let\endtabulary\endtabular
\renewenvironment{tabular}{\rowcolors{2}{white}{shadecolor}\tabulary} {\endtabulary}
\usepackage{footnote}
\makesavenoteenv{tabular}
그렇다면 \tabular가 Float: Figure 환경에 있을 때 이 모든 기능을 어떻게 끄나요?
답변1
귀하가 요구하는 내용을 잘 이해한다면 패키지를 사용하여 그렇게 할 수 있습니다 etoolbox
.
\documentclass[a4paper, 11pf]{article}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[table, x11names]{xcolor}
\usepackage{booktabs, caption}
\colorlet{shadecolor}{LightSteelBlue1}
\let\mytoprule\toprule
\renewcommand{\toprule}{\mytoprule[2pt]}
\let\mybottomrule\bottomrule
\renewcommand{\bottomrule}{\mybottomrule[2pt]}
\let\mymidrule\midrule
\renewcommand{\midrule}{\mymidrule[1pt]}
\let\tabulary\tabular
\let\endtabulary\endtabular
\renewenvironment{tabular}{\ifbool{intableenv}{\rowcolors{2}{white}{shadecolor}}{}\tabulary} {\endtabulary}
\usepackage{etoolbox}
\newbool{intableenv}
\AtBeginEnvironment{table}{\booltrue{intableenv}}%{}{}
\AtEndEnvironment{table}{\boolfalse{intableenv}}{}{}
\begin{document}
\begin{table}[!h]
\centering
\caption{A Zebra Table}
\begin{tabular}{llccc}
\toprule
\multicolumn{2}{c} {}& \textbf{Head 1} & \textbf{Head 2} & \textbf{Head 3} \\
\midrule
A & & & & \\
B & & & & \\
C & & & & \\
D & & & & \\
E & & & & \\
F & & & & \\
G & & & & \\
\bottomrule
\end{tabular}%
\end{table}
\begin{figure}[!h]
\centering
\begin{tabular}{llccc}
\toprule
\multicolumn{2}{c}{} & \textbf{Head 1} & \textbf{Head 2} & \textbf{Head 3} \\
\midrule
A & & & & \\
B & & & & \\
C & & & & \\
D & & & & \\
E & & & & \\
F & & & & \\
G & & & & \\
\bottomrule
\end{tabular}%
\caption{Same table}
\end{figure}
\end{document}