我一直在处理一个大型文档,其中经常使用\include{}
edlongtable
环境和siunitx
。最近,较长的表达式使用siunitx
导致编译错误,我无法解决。这些siunitx
表达式中很可能存在另一个问题,但我无法找出确切的问题。
我正在使用texlive
和archlinux
作为emacs
我auctex
的编辑环境。
main.tex
文件:
\documentclass[11pt,letterpaper]{article}
%PACKAGES
%\usepackage[english]{babel}
%\usepackage[utf8x]{inputenc}
\usepackage{siunitx}%si unit typesetting
\usepackage{amsmath}%math typesetting stuff
\usepackage{fancyhdr}%header & footer stuff
\usepackage[margin=1in]{geometry}%page margins & stuff
%\usepackage{multicol}%multicolumn stuff in tables
\usepackage{url}%nice url typesetting
\usepackage{textcomp}%used for \textrangle & similar--adds symbols for text environment
\usepackage{graphicx}%for pictures and stuff
\usepackage{multicol}
\usepackage{booktabs}%adds additional table commands (\toprule, etc.)
\usepackage{longtable}%handles tables spanning multiple pages
\usepackage{hyperref}%adds pdf hyperlinks for document references (e.g., table of contents)
%SIUNITX STUFF
\let\DeclareUSUnit\DeclareSIUnit
\let\US\SI
\let\us\si%means of separating SI and US units
%us unit declarations
\DeclareUSUnit\inch{in}
\DeclareUSUnit\foot{ft}
\DeclareUSUnit\pound{lb}
\DeclareUSUnit\mile{mi}
\DeclareUSUnit\gallon{gal}
\DeclareUSUnit\horsepower{hp}
\DeclareUSUnit\britishthermalunit{Btu}%british thermal unit
\DeclareUSUnit\slug{slug}
%si unit declarations
\DeclareSIUnit\atmosphere{atm}
\DeclareSIUnit\year{y}
\DeclareSIUnit\lightspeed{c}
\DeclareSIUnit\lightyear{ly}
\DeclareSIUnit\dyne{dyn}
\DeclareSIUnit\ergon{erg}
\DeclareSIUnit\calorie{cal}
\DeclareSIUnit\revolution{rev}
\DeclareSIUnit\gauss{G}
%siunitx setup stuff
\sisetup{inter-unit-product = $\cdot$}
%\sisetup{per-mode = fraction}
\sisetup{per-mode = symbol}%choose one or the other
%END SIUNITX STUFF
%NEW COMMANDS
\providecommand{\e}[1]{%scientific notation command
\ensuremath{\times 10^{#1}}
}
\newcommand{\abs}[1]{%absolute value command
\left|#1\right|
}
\newcommand{\tablesection}[1]{%new section in 2-column table
\rhead{#1}
\addcontentsline{toc}{section}{#1} \\
\toprule
\multicolumn{2}{l}{#1} \\
\midrule
}
\newcommand{\tablesubsection}[1]{%new subsection in 2-column table
\addcontentsline{toc}{subsection}{#1} \\
\cmidrule(r){1-2}
\multicolumn{2}{c}{#1} \\
\cmidrule(r){1-2}
}
\newcommand{\notabene}[1]{%use to add multicolumn notes & stuff for a 2-column table
\multicolumn{2}{c}{
\begin{minipage}[t]{\textwidth}
\textbf{N.B.} {#1}
\end{minipage}} \\
}
%END NEW COMMANDS
%MISC DOCUMENT SETTINGS
\setlength\parindent{0pt}%removes paragraph indentation
\setlength\parskip{0em}%remove line spacing for table of contents
%BEGIN DOCUMENT PROPER
\begin{document}
%table of contents & similar
\tableofcontents
\setlength\parskip{1em}%uses default paragraph spacing after T.O.C.
\include{foo}
foo.tex
文件:
\begin{longtable}{p{0.5\textwidth} p{0.5\textwidth}}
\tablesection{Chapter 4: The Laws of Motion}
\tablesubsection{General Motion Formul\ae}
\(F_g = G\displaystyle\frac{m_1m_2}{r^2}\) & The magnitude of the gravitational force $F_g$ where $G = \SI{6.67e-11}{\newton\meter\squared\per\kilo\gram\squared}$ is the universal gravitation constant, and $r$ is the distance between the two objects with masses $m_1$ and $m_2$ \\
\end{longtable}
一个有趣的发展:这不会在或中编译TeXWorks
,emacs
但是auctex
它将要编译时出现警告背页另一个有趣的发展:Overleaf 需要\sisetup{inter-unit-product = $\cdot$}
同时满足以下两个条件TeXWorks
,emacs
否则将无法编译:\sisetup{inter-unit-product = \cdot}
答案1
(该答案涉及查询的更新版本,其中 OP 提供了有关设置siunitx
包时使用的选项的具体信息。)
指令
\sisetup{inter-unit-product = $\cdot$}
是不正确的。应该是
\sisetup{inter-unit-product = \cdot}
通过此修改,您的示例代码可以正确编译。