帶有子文件的 siunitx 自訂文件

帶有子文件的 siunitx 自訂文件

我最近決定將我的論文分成幾個嵌套文件,如下所示:

% Main.tex

\documentclass{memoir}
\usepackage{subfiles}
\usepackage{siunitx} 
\include{units}
\begin{document}
\subfile{pre_textual} % ToC, lists, etc.
\subfile{textual}
\subfile{pos_textual}
\end{document}

單位檔案與 main.tex 位於同一目錄中。以及通常的子文件:

%textual.tex

\documentclass[../../main.tex]{subfiles} %this is because it's nested
\begin{document}
\subfile{chapter1}
\subfile{chapter2}
\end{document}

%chapter1.tex

\documentclass[../../../main.tex]{subfiles} %this is because it's nested
\begin{document}
text yada \si{\CustomUnit}
\end{document}

問題是,當我編譯子檔案(文字或章節)時,它找不到單位檔案。如果我將完整路徑新增至units.tex我會收到錯誤

Can't write to the file

編輯:

我的units.tex 檔案看起來像這樣

\DeclareSIUnit{\lix}{g/cm^2\day}
\DeclareSIUnit{\molp}{\mole\%}
\DeclareSIUnit{\taxaresf}{\degreeCelsius/\minute}

除了它有更多的行和足夠的單位讓我創建一個單獨的文件。

答案1

input我找到的解決方案是使用而不是包含來添加完整路徑。如果您僅使用沒有完整路徑的輸入也將無法運作。

所以我最終是這樣的:

\usepackage{siunitx}           
\input{D:/OneDrive/Documents/Thesis_latex/units}

發生這種情況是因為subfiles包不喜歡\include序言中的 s。

手冊第 2.3 節:

主檔案的前導碼可以輸入(不是 \include 也不是 \subfile)檔案(定義和速記指令的 vg 檔案),子檔案也可以。

相關內容