我想创建一个简单的 LaTeX 表格。由于我已经使用 创建了一个更复杂的表格tabularx
,我决定直接剪切并粘贴代码。但为什么会出现错误?谢谢任何帮助^^
\documentclass[]{scrartcl}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage[showframe=false]{geometry}
\usepackage{changepage}
\usepackage{colortbl}
\usepackage{array}
\begin{document}
\begin{figure}
\begin{adjustwidth}{-3cm}{}
\begin{center}
\footnotesize
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\begin{tabularx} {20.3cm} {@{} l Y @{}} \\
\arrayrulecolor{blue}
\toprule[0.14em]
\textbf{Variable} & \textbf{Description} \\
\cmidrule(l{.75em}){1-1} \cmidrule(l{.75em}){2-2}
STI_30 & Member of the STI Index \\
CPFIS & CPF Investment Scheme \\
Produce_Full_SR & Produce Full Sustainability Report \\
Full_SR_Assured & External Audit of Full Sustainability Report \\
Sus_Sec_in_AR & Sustainability Section in Annual Report provided \\
Sus_Sec_Assured & External Audit of Sustainability Section in Annual Report \\
GRI & Compliance with Global Reporting Index \\
Materiality & Materiality of Disclosure \\
Has_Sus_Efforts & Has Sustainability Efforts \\
C_or_S & Stewardship in Sustainability Efforts in general \\
Water_Efforts & Has Water Efforts \\
C_or_S1 & Stewardship in Water Conservational Efforts \\
\midrule
EnergyD & Energy Disclosure \\
EmissionsD & Emissions Disclosure \\
WasteD & Waste Disclosure \\
WaterD & Water Disclosure \\
FullD & Full Disclosure (Energy, Emissions, Waste, Water) \\
AnyD & At Least One the Four Disclosures \\
\bottomrule[0.14em]
\addlinespace[.75ex]
\end{tabularx}
\par
\normalsize
\end{center}
\end{adjustwidth}
\end{figure}
\end{document}
答案1
请参阅以下更正和简化的代码。我_
用以下代码屏蔽了您的使用\_
:
\documentclass[]{scrartcl}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage[showframe=false]{geometry}
\usepackage{changepage}
\usepackage{colortbl}
\usepackage{array}
\begin{document}
\begin{figure}
\begin{adjustwidth}{-3cm}{}
\begin{center}
\footnotesize
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\begin{tabularx} {20.3cm} {@{} l Y @{}} \\
\arrayrulecolor{blue}
\toprule[0.14em]
\textbf{Variable} & \textbf{Description} \\
\cmidrule(l{.75em}){1-1} \cmidrule(l{.75em}){2-2}
STI\_30 & Member of the STI Index \\ % <=======================================
CPFIS & CPF Investment Scheme \\
Produce\_Full\_SR & Produce Full Sustainability Report \\
Full\_SR\_Assured & External Audit of Full Sustainability Report \\
Sus\_Sec\_in\_AR & Sustainability Section in Annual Report provided \\
\midrule
EnergyD & Energy Disclosure \\
EmissionsD & Emissions Disclosure \\
WasteD & Waste Disclosure \\
WaterD & Water Disclosure \\
FullD & Full Disclosure (Energy, Emissions, Waste, Water) \\
AnyD & At Least One the Four Disclosures \\
\bottomrule[0.14em]
\addlinespace[.75ex]
\end{tabularx}
\par
\normalsize
\end{center}
\end{adjustwidth}
\end{figure}
\end{document}
编译无误
答案2
问题在于下划线 ( _
) 表示下标并进入数学模式(因此出现带有 的错误消息$
),解决方法是\
在下划线前面放置一个反斜杠 ( ),以便\_