main.tex と入力 child.tex の間に競合があります

main.tex と入力 child.tex の間に競合があります

を実行するとchild.tex、正しい書式でテーブルが作成されます。

main.texを とともに実行すると\input{child.tex}、 のテーブルがchild.tex間違った書式で作成されます。

child.texコード元:エラー: 外部 par モードではありません: 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

あなたはできるない1 つの TeX コードに 、 、 コマンドが\documentclass2\begin{document}つあります。\end{document}

以下のMWEを参照してください(パッケージは、filecontents両方のTeXコードを1つのMWEコンパイルに含めるためにのみ使用されます。いらないコード内で使用してください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 が提供されます:

結果の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}

そして2番目main.tex

\documentclass[%
  12pt,a4paper,
  x11names,table
]{article}

\usepackage{tcolorbox}
\usepackage[skip=1ex]{caption}

\begin{document}
\input{child.tex}
\end{document}

私たちとあなた自身のために、パッケージのドキュメントを読んでください。filecontentsたとえば、texdoc filecontentsターミナル/コンソールに入力して Enter キーを押します... このパッケージは、あなたの場合のようにテスト目的で MWE を構築するのに非常に役立ちます...

関連情報