1

I wanna create a simple LaTeX table. Since I have created a more complex table using tabularx, I decided to just cut and paste the codes. But why the error? Thx for any help^^

\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}
  • Problem here are the underscores (_) that indicate subscripts and go into mathematical mode (hence the error message with the $) , a way to solve it is to place a backslash in front of the underscores so \_ – albert Jan 1 '19 at 18:18
1

Problem here are the underscores (_) that indicate subscripts and go into mathematical mode (hence the error message with the $), a way to solve it is to place a backslash (\) in front of the underscores so \_

|improve this answer|||||
1

Please see the following corrected and reduced code. I masked your used _ with \_:

\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}

It compiles without error to

enter image description here

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.