
을 실행하면 child.tex
올바른 형식으로 테이블이 생성됩니다.
main.tex
, with 을 실행하면 잘못된 형식으로 \input{child.tex}
테이블이 생성됩니다.child.tex
child.tex
코드:오류: 외부 파 모드가 아닙니다: tcolorbox 내부의 테이블
\documentclass[12pt,a4paper,
x11names,table]{article}
\usepackage{tcolorbox}
\usepackage[skip=1ex]{caption}
\begin{document}
\begin{tcolorbox}[colback=gray!5!white,colframe=gray!75!black,title=\large{In the next lines I'm trying to insert the same in a box}]
\centering
\begin{tabular}{|c|c|c|c|}
\hline
% after \\: \hline or \cline{col1-col2} \cline{col3-col4} ...
a& b & T/F & dif\\ \hline
1 & 2 & False & -1\\
2 & 4 & False & -2\\
\hline
\end{tabular}\\
\captionof{figure}{Caption Table}\label{tab:table-out}
\end{tcolorbox}
\end{document}
그리고 main.tex
:
\documentclass[12pt,a4paper]{article}
a lot of usepackage
\begin{document}
\input{child.tex}
\end{document}
main.tex
내부 형식을 어떻게 지울 수 있나요 child.tex
?
답변1
당신은 할 수 있습니다~ 아니다하나의 TeX 코드에 두 개의 \documentclass
, \begin{document}
및 명령이 있습니다 !\end{document}
다음 MWE를 참조하십시오(패키지는 filecontents
MWE를 컴파일하는 하나의 TeX 코드를 모두 포함하는 데에만 사용됩니다.필요하지 않다filecontents
코드에 사용하세요 !) 그리고 다음에 대한 코드의 주석을 참조하세요 main.tex
.
\RequirePackage{filecontents}
\begin{filecontents}{child.tex}
\begin{tcolorbox}[colback=gray!5!white,colframe=gray!75!black,title=\large{In the next lines I'm trying to insert the same in a box}]
\centering
\begin{tabular}{|c|c|c|c|}
\hline
% after \\: \hline or \cline{col1-col2} \cline{col3-col4} ...
a& b & T/F & dif\\ \hline
1 & 2 & False & -1\\
2 & 4 & False & -2\\
\hline
\end{tabular}\\
\captionof{figure}{Caption Table}\label{tab:table-out}
\end{tcolorbox}
\end{filecontents}
% your code main.tex following % <===========================================
\documentclass[%
12pt,a4paper,
x11names,table
]{article}
\usepackage{tcolorbox} % all needed packages for child.tex have to be called here!
\usepackage[skip=1ex]{caption}
\begin{document}
\input{child.tex} % only code for environment tcolorbox
\end{document}
결과 PDF를 제공합니다.
두 파일을 모두 따르면 동일한 출력을 얻을 수 있습니다.
첫 번째 child.tex
:
\begin{tcolorbox}[colback=gray!5!white,colframe=gray!75!black,title=\large{In the next lines I'm trying to insert the same in a box}]
\centering
\begin{tabular}{|c|c|c|c|}
\hline
% after \\: \hline or \cline{col1-col2} \cline{col3-col4} ...
a& b & T/F & dif\\ \hline
1 & 2 & False & -1\\
2 & 4 & False & -2\\
\hline
\end{tabular}\\
\captionof{figure}{Caption Table}\label{tab:table-out}
\end{tcolorbox}
두 번째 main.tex
:
\documentclass[%
12pt,a4paper,
x11names,table
]{article}
\usepackage{tcolorbox}
\usepackage[skip=1ex]{caption}
\begin{document}
\input{child.tex}
\end{document}
예를 들어 터미널/콘솔에 filecontents
입력 하고 Enter 키를 눌러 패키지 문서를 읽어 보십시오 . 이 패키지는 귀하의 경우와 같은 테스트 목적으로 MWE를 구축하는 데 매우 유용합니다.texdoc filecontents