
Cuando ejecuto child.tex
, la tabla se crea con el formato correcto.
Cuando ejecuto main.tex
, con \input{child.tex}
, la tabla se child.tex
crea con un formato incorrecto.
child.tex
código de:Error: no en modo par externo: tabla dentro de 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}
Y en main.tex
:
\documentclass[12pt,a4paper]{article}
a lot of usepackage
\begin{document}
\input{child.tex}
\end{document}
¿Cómo puedo borrar el formato del main.tex
interior child.tex
?
Respuesta1
Puedeno¡tenga dos \documentclass
comandos \begin{document}
y \end{document}
en un código TeX!
Consulte el siguiente MWE (el paquete filecontents
solo se usa para tener ambos códigos TeX en un MWE compilador, debe hacerlono necesitapara usar filecontents
en su código!) y consulte los comentarios en el código para 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}
dándote el pdf resultante:
Obtendrá el mismo resultado al seguir ambos archivos.
Primero 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}
y segundo main.tex
:
\documentclass[%
12pt,a4paper,
x11names,table
]{article}
\usepackage{tcolorbox}
\usepackage[skip=1ex]{caption}
\begin{document}
\input{child.tex}
\end{document}
Háganos un favor a nosotros y a usted mismo y lea la documentación del paquete, filecontents
por ejemplo, escribiendo texdoc filecontents
en su terminal/consola y presione y luego ingrese... Este paquete es muy útil para construir MWE con fines de prueba como en su caso...