4

I cannot get the | line to appear in a fraction in a tabular. Could someone please tell me what I am doing wrong??

\documentclass{article}
\usepackage{amssymb, amsmath}

\begin{document}
    \begin{center}\vspace{1cm}
        \begin{tabular}{c c}
            \toprule
            \textbf{Form} & \textbf{Value}\\
            \midrule
            $\frac{ Pr( \textsc{like-ChicagoBear(A) | Live-in-illinois(A)} ) }{Pr(\textsc{Like-ChicagoBear(A) | Not-live-in-illinois})}$ & 17.8\\
            \bottomrule
        \end{tabular}
        \captionof{table}{\color{Green} Location Examples}
        \label{table:location_examples}
    \end{center}\vspace{1cm}
\end{document}
2
  • That's because it is inside of a \textsc{} argument (which takes it momentarily out of math mode). Mar 30, 2015 at 14:18
  • If you want to post an answer I can approve and close this?
    – codehitman
    Mar 30, 2015 at 14:21

1 Answer 1

4

Some suggestions:

  • Most importantly, place the text material before and after the vertical bar inside separate \textsc{...} directives.

  • Instead of \frac, use \dfrac (requires the amsmath package). The terms in the numerator and denominator will look much less cramped.

  • Consider using \big-sized outer parentheses in both the numerator and denominator.

  • Instead of inputting a vertical bar, i.e., |, directly, I suggest you use \mid. Doing so will give you better spacing when used in display-style or text-style math mode -- as is the case when using \dfrac. If you use big-sized outer parentheses, you may want to use \bigm| to get a big-sized version of \mid.

  • Last but not least, write \Pr instead of just Pr -- "Pr" is a "math operator" and should be typeset in upright letters, not in math-italics.

enter image description here

\documentclass{article}
\usepackage{booktabs,caption,amsmath}
\usepackage[dvipsnames]{xcolor}
\begin{document}

\begin{center}
\begin{tabular}{c c}
\toprule
  \textbf{Form} & \textbf{Value}\\
  \midrule
  $\dfrac{ \Pr \bigl( \textsc{Like-ChicagoBear(A)} \bigm| 
                      \textsc{Live-in-Illinois(A)} \bigr)}
         { \Pr \bigl( \textsc{Like-ChicagoBear(A)} \bigm| 
                      \textsc{Not-Live-in-Illinois}\bigr)}$ 
  & 17.8\\
\bottomrule
\end{tabular}
\captionof{table}{\color{Green} Location Examples}
\label{table:location_examples}
\end{center}

\end{document}
5
  • Thanks! I was wondering why my table is so crammed. After adding your changes it looks readable now :D
    – codehitman
    Mar 30, 2015 at 14:49
  • My cells are crammed, anyway to increase the height and vertically centre the text?
    – codehitman
    Mar 30, 2015 at 14:58
  • @codehitman - Do all of the "crammed" cells contain fractions? If so, \dfrac instead of \frac will provide much relief. Fractions, large sums, and integral symbols should be centered by default. Are you maybe asking about how to go about increasing the vertical separation between rows?
    – Mico
    Mar 30, 2015 at 15:02
  • Instead of \mid, since you are using \bigl(, you can use \bigm|.
    – Manuel
    Mar 31, 2015 at 11:55
  • @Manuel - Many thanks for this good suggestion. I've updated my answer accordingly.
    – Mico
    Mar 31, 2015 at 13:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .