Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am using stata, a statistical software. It has a program called -tabout-, that generates output (basically tables containing descriptive statistics incl means of variables etc) code for TeX.

Currently for the table I need I obtain the following code

\begin{center}
\footnotesize
\newcolumntype{Y}{>{\raggedleft\arraybackslash}X}
\begin{tabularx} {10cm} {@{} l Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y@{}} \\
\toprule
 & \multicolumn{3}{c}{orgevent} \\
spontevent&0&1&Total \\
\cmidrule(l{.75em}){2-4} \cmidrule(l{.75em}){5-6}
&Relative&Relative&Relative \\
\midrule
0 (97\%)&0.016\%&0.011\%&0.016\% \\
1 (2\%)&0.044\%&&0.044\% \\
Total (100\%)&0.017\%&0.011\%&0.017\% \\
\bottomrule
\addlinespace[.75ex]
\scriptsize{\emph{Source: }#}
\end{tabularx}
\normalsize
\end{center} 

But my LaTeX compiler points to an error in the line

 \end{tabularx}

The error reported is

"pdflatex> ! You can't use the 'macro parameter character #' in restricted mode"

Please help understand what's going on and how can I see the table?

After regenerating the code from stata, again error bit of a different kind

\begin{center}
\footnotesize
\newcolumntype{Y}{>{\raggedleft\arraybackslash}X}
\begin{tabularx} {10cm} {@{} l Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y@{}} \\
\toprule
 & \multicolumn{3}{c}{orgevent} \\
spontevent&0&1&Total \\
\cmidrule(l{.75em}){2-4} \cmidrule(l{.75em}){5-6}
&Relative&Relative&Relative \\
\midrule
0&0.016\%&0.011\%&0.016\% \\
1&0.044\%&&0.044\% \\
Total&0.017\%&0.011\%&0.017\% \\
\begin{center}
\footnotesize
\newcolumntype{Y}{>{\raggedleft\arraybackslash}X}
\begin{tabularx} {10cm} {@{} l Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y@{}} \\
\toprule
 & \multicolumn{3}{c}{orgevent} \\
spontevent&0&1&Total \\
\cmidrule(l{.75em}){2-4} \cmidrule(l{.75em}){5-6}
&Relative&Relative&Relative \\
\midrule
0 (97\%)&0.016\%&0.011\%&0.016\% \\
1 (2\%)&0.044\%&&0.044\% \\
Total (100\%)&0.017\%&0.011\%&0.017\% \\
\bottomrule
\addlinespace[.75ex]
%\scriptsize{\emph{Source: }#}
\end{tabularx}
\normalsize
\end{center}

Are there any TeXperts who have some experience with stata as well? As you can see, the code seems to be repeated twice

share|improve this question
3  
That's the lonely # in the "Source" line. You probably need to fill the source field in Stata. –  egreg Jun 7 '12 at 22:38
    
@egreg: Thanks, I had guessed so. I get the output now but doesn't seem to be what I need. Shall have a look at it again. Cheers –  Abhimanyu Arora Jun 7 '12 at 22:39
1  
@egreg I was about to say the same thing :-). Post your comment as an answer as it has resolved the problem. –  azetina Jun 7 '12 at 22:43
1  
@AbhimanyuArora The errors comes because you did not end the first tabular and center commands. Check your code. –  azetina Jun 7 '12 at 22:58
1  
@AbhimanyuArora Note that you are asking several questions in one post. Sometimes it is best to isolate specific questions as other members may aid in their expertise. –  azetina Jun 7 '12 at 23:07
show 1 more comment

1 Answer 1

up vote 5 down vote accepted

It's the lonely # in the "Source" line. You probably need to fill the source field in Stata or find a way to not produce the line.

However, I'd input that source line as

\multicolumn{17}{@{}l}{\scriptsize\emph{Source}: ...}

so as not to enlarge the first column. Alternatively,

\makebox[0pt][l]{\scriptsize\emph{Source}: ...}

which doesn't need to know the number of columns to span.

By the way, single characters like # $ & ˜ _ ˆ % { } all have special meanings and require a \ before them to use them as printing character.

share|improve this answer
    
Grazie @egreg ,I simply added a % for now, regenerated the code for the table but get a different error (pdflatex> ! missing \cr inserted), shall edit the question –  Abhimanyu Arora Jun 7 '12 at 22:51
1  
@AbhimanyuArora Somehow your last code has now duplicate lines; remove those lines: \begin{center} \footnotesize \newcolumntype{Y}{>{\raggedleft\arraybackslash}X} \begin{tabularx} {10cm} {@{} l Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y@{}} \\toprule & \multicolumn{3}{c}{orgevent} \spontevent&0&1&Total \\cmidrule(l{.75em}){2-4} \cmidrule(l{.75em}){5-6} &Relative&Relative&Relative \\midrule 0 (97\%)&0.016\%&0.011\%&0.016\% \1 (2\%)&0.044\%&&0.044\% \Total (100\%)&0.017\%&0.011\%&0.017\% \\bottomrule \addlinespace[.75ex] \end{tabularx} \normalsize \end{center} –  Gonzalo Medina Jun 7 '12 at 23:00
    
@GonzaloMedina: Thanks very much indeed –  Abhimanyu Arora Jun 7 '12 at 23:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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