理解できない\input

理解できない\input

これは非常に愚かな質問のように思われるかもしれませんが、xelatex を使用して入力するファイルを識別する方法がわかりません\input。正しいことをしていると思うのですが、何らかの理由で機能しません。

私のメインファイルは次のようになります:

\documentclass{report}
\begin{document}
\input(testinput.tex)
\end{document}

testinput.tex同じディレクトリにというファイルがあります。そのディレクトリで実行すると、xelatexファイルが見つからないというエラーが表示されますが、ファイル名を入力すると正常に実行されます。

This is XeTeX, Version 3.14159265-2.6-0.99996 (TeX Live 2016) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2017/01/01> patch level 3
Babel <3.9r> and hyphenation patterns for 83 language(s) loaded.
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/report.cls
Document Class: report 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/size10.clo)) (./test.aux)
! I can't find file `(testinput.tex)'.
l.3 \input(testinput.tex)

(Press Enter to retry, or Control-D to exit)
Please type another input file name: testinput.tex
(./testinput.tex) [1] (./test.aux) )
Output written on test.pdf (1 page).
Transcript written on test.log.

何が間違っているのか困惑しています。.tex拡張機能なしでこれを試してみましたが、同じ結果になりました。

答え1

入力内容()から、ファイル名を括弧 ( ) で囲むことが推奨されています。LaTeX コマンドに引数 (必須) を渡す正しい方法は、中括弧 ( {}) を使用することです。したがって、次のコードを使用する必要があります。

\documentclass{report}
\begin{document}
\input{testinput.tex}
\end{document}

ちなみに、これはどのエンジンからも独立しています。

アップデート:LaTeX は自動的に追加するので、.tex以下も使用できます。

\documentclass{report}
\begin{document}
\input{testinput}
\end{document}

ただし、ここで LaTeX はtestinputまずファイルをチェックし、次に を参照することに注意してください。これが、ファイルを入力するときにtestinput.tex拡張子を使用する良い理由であると考えられます。.tex

関連情報