Graphics, Figures & TablesFile ended while scanning use of \TX@get@body

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
wmcass
Posts: 1
Joined: Mon Aug 01, 2016 4:40 am

File ended while scanning use of \TX@get@body

Post by wmcass »

Hi,

Am using a stata package to output to latex and create tables in a latex package that I am unfamiliar with. Not quite sure what the bug in the outputted latex code (below) is and would appreciate advice.

This generates a "File ended while scanning use of \TX@get@body". I've read through some help, but can't find a solution.

Thanks in advance for help

Code: Select all

\documentclass{article}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{array}
 
\begin{document}
 
\begin{center}
\footnotesize
\newcolumntype{Y}{>{\raggedleft \arraybackslash}X}
\begin{tabularx} {10 cm} {@{} l Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y@{}} \\
\toprule
\cmidrule(l{.75em}){2-4}
\textbf{industry}&\textbf{nonunion}&\textbf{union}&\textbf{Total} \\
\midrule \textbf{Race: white) \\
Ag/Forestry/Fisheries&8&1&9 \\
Mining&2&0&2 \\
Construction&14&2&16 \\
Manufacturing&155&40&195 \\
Transport/Comm/Utility&31&28&59a \\
Wholesale/Retail Trade&188&18&206 \\
Finance/Ins/Real Estate&127&6&133 \\
Business/Repair Svc&41&3&44 \\
Personal Services&33&2&35 \\
Entertainment/Rec Svc&9&2&11 \\
Professional Services&372&160&532 \\
Public Administration&65&37&102 \\
\textbf{Total}&1,045&299&1,344 \\
\midrule \textbf{Race: black} \\
Ag/Forestry/Fisheries&2&1&3 \\
Construction&2&1&3 \\
Manufacturing&76&43&119 \\
Transport/Comm/Utility&8&19&27 \\
Wholesale/Retail Trade&51&3&54 \\
Finance/Ins/Real Estate&16&3&19 \\
Business/Repair Svc&9&4&13 \\
Personal Services&25&3&28 \\
Entertainment/Rec Svc&3&0&3 \\
Professional Services&119&58&177 \\
Public Administration&35&16&51 \\
\textbf{Total}&346&151&497 \\
\midrule \textbf{Race: other) \\
Construction&1&0&1 \\
Manufacturing&3&1&4 \\
Transport/Comm/Utility&0&1&1 \\
Finance/Ins/Real Estate&1&0&1 \\
Business/Repair Svc&1&1&2 \\
Professional Services&9&2&11 \\
Public Administration&1&3&4 \\
\textbf{Total}&16&8&24 \\
\bottomrule
\addlinespace[.75ex]
\end{tabularx}
\par
\scriptsize{\emph{Source: }nlsw88.dta}
\normalsize
\end{center}
 
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

File ended while scanning use of \TX@get@body

Post by Johannes_B »

An error message like that tells you that TeX is for some reason reading further than it should or needs to. Most often, a closing brace is missing.

In your case, the reason is pretty simple. You have been a bit slopy while typing. \midrule \textbf{Race: white) \\ If we minimalize that further, we get \textbf{) <- All La/TeX finds here is an opening brace and a closing parenthesis that it typesets in bold, but it never sees the closing brace.

Code: Select all

\documentclass{article}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{array}
\usepackage{ragged2e}
\usepackage{showframe}% Visualize page margins
\usepackage{color}

\newcommand\tabhighlight{\textbf}
\begin{document}

\begin{center}
	\footnotesize
	\renewcommand\tabhighlight{\bfseries\leavevmode\color{gray!70!black}}% playing around a bit
	\newcolumntype{Y}{>{\raggedleft \arraybackslash}X}
	\begin{tabularx} {10 cm} { >{\RaggedLeft}p{12em} YYY } 
		\toprule
		\cmidrule(l{.75em}){2-4}
		\tabhighlight{industry}&\tabhighlight{nonunion}&\tabhighlight{union}&\tabhighlight{Total} \\
		\midrule \tabhighlight{Race: white} \\
			Ag/Forestry/Fisheries            & 8     & 1   & 9 \\
			Mining                           & 2     & 0   & 2 \\
			Construction                     & 14    & 2   & 16 \\
			Manufacturing                    & 155   & 40  & 195 \\
			Transport/Comm/Utility           & 31    & 28  & 59a \\
			Wholesale/Retail Trade           & 188   & 18  & 206 \\
			Finance/Ins/Real Estate          & 127   & 6   & 133 \\
			Business/Repair Svc              & 41    & 3   & 44 \\
			Personal Services                & 33    & 2   & 35 \\
			Entertainment/Rec Svc            & 9     & 2   & 11 \\
			Professional Services            & 372   & 160 & 532 \\
			Public Administration            & 65    & 37  & 102 \\
			\tabhighlight{Total}                   & 1,045 & 299 & 1,344 \\
			\midrule \tabhighlight{Race: black} \\
			Ag/Forestry/Fisheries            & 2     & 1   & 3 \\
			Construction                     & 2     & 1   & 3 \\
			Manufacturing                    & 76    & 43  & 119 \\
			Transport/Comm/Utility           & 8     & 19  & 27 \\
			Wholesale/Retail Trade           & 51    & 3   & 54 \\
			Finance/Ins/Real Estate          & 16    & 3   & 19 \\
			Business/Repair Svc              & 9     & 4   & 13 \\
			Personal Services                & 25    & 3   & 28 \\
			Entertainment/Rec Svc            & 3     & 0   & 3 \\
			Professional Services            & 119   & 58  & 177 \\
			Public Administration            & 35    & 16  & 51 \\
			\tabhighlight{Total}                   & 346   & 151 & 497 \\
			\midrule \tabhighlight{Race: other} \\
				Construction                   & 1     & 0   & 1 \\
				Manufacturing                  & 3     & 1   & 4 \\
				Transport/Comm/Utility         & 0     & 1   & 1 \\
				Finance/Ins/Real Estate        & 1     & 0   & 1 \\
				Business/Repair Svc            & 1     & 1   & 2 \\
				Professional Services          & 9     & 2   & 11 \\
				Public Administration          & 1     & 3   & 4 \\
				\tabhighlight{Total}                 & 16    & 8   & 24 \\
				\bottomrule
				\addlinespace[.75ex]
			\end{tabularx}
			\par
			{\scriptsize\emph{Source: }nlsw88.dta}
%			\scriptsize{\emph{Source: }nlsw88.dta}%JB: That is wrong
			\normalsize
		\end{center}

		\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply