2

to explain my problem, please look at this table:

enter image description here

1) I want to bring the red part closer to the middle, so that the three columns are more centered.

2) I want to align the blue part in one vertical line. I tried to use {flalign*}, but this aligns the equations with the column on the top, and not the "Profitability calculation".

This is the code that I use:

\documentclass[12pt]{article}
\usepackage{setspace,amsmath,graphicx,float}
\usepackage[english]{babel}
\usepackage{boldline}
\usepackage{array}
\usepackage[left=3cm,top=3.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\usepackage{times}
\usepackage{threeparttable}
\usepackage[margin=1cm]{caption}
\usepackage{amssymb}
\usepackage{tabularx}

\begin{document}
\begin{table}[H]
\centering
\small
\caption[xxx]{Example calculation for a two-product SSNIP test \citep{QuantTech}.}
\begin{threeparttable}
\begin{tabularx}{\textwidth}{p{20em} >{\centering\arraybackslash}p{8em}  >{\centering\arraybackslash}p{7em}}    
\hlineB{3}
  & Product 1 & Product 2  \\ \hline
Margin & 10\% & 20\% \\
Diversion ratio & 0.29 & 0.5 \\ 
Own-price elasticity of demand & 2 & 4 \\ 
Ratio of prices $p_2 / p_1$ & 1 & 1 \\                       
\hlineB{3}
\end{tabularx}
\begin{tablenotes}
\setlength{\belowdisplayskip}{0pt} \setlength{\belowdisplayshortskip}{0pt}
\setlength{\abovedisplayskip}{0pt} \setlength{\abovedisplayshortskip}{0pt}
\item Profitability calculation:\\
\begin{align*}
\frac{p_1 - c_1}{p_1} \overset{?}{\leqslant} \frac{1}{\eta_{11}(p_1,p_2.\ldots,p_J)} + \frac{p_2 - c_2}{p_2} \frac{p_2}{p_1} DR_{12}, \qquad 0.1 \leqslant \frac{1}{2} + 0.2 \times 1 \times 0.29 = 0.56
 \end{align*}

\begin{align*}
\frac{p_2 - c_2}{p_1} \overset{?}{\leqslant} \frac{1}{\eta_{22}(p_1,p_2.\ldots,p_J)} + \frac{p_1 - c_1}{p_1} \frac{p_1}{p_2} DR_{21}, \qquad 0.2 \leqslant \frac{1}{4} + 0.1 \times 1 \times 0.5 = 0.30
\end{align*}

\end{tablenotes}
\end{threeparttable}
\label{ExampleSSNIP}   
\end{table}
\end{document}

I'm grateful for any help - thanks!

2

If you really want your table to fill the text width (you shouldn't, unless you're doing two column typesetting), at least don't use \small.

You don't need threeparttable, in this case. Just use \raggedright.

I used newtxtext and newtxmath. You can use mathptmx (but the results are poorer); never ever use times if you have math in your document.

\documentclass[12pt]{article}
\usepackage[left=3cm,top=3.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\usepackage{amsmath}
\usepackage{newtxtext,newtxmath}
\usepackage{booktabs}
\usepackage{natbib}
\usepackage[margin=1cm]{caption}

\begin{document}
\begin{table}

\caption[xxx]{Example calculation for a two-product SSNIP test \citep{QuantTech}.}
\label{ExampleSSNIP}   

\centering

\begin{tabular*}{\textwidth}{
  @{\hspace{.1\textwidth}\extracolsep{\fill}}
  l c c
  @{\hspace{.1\textwidth}}
}
\toprule
                               & Product 1 & Product 2 \\
\midrule
Margin                         & 10\%      & 20\%      \\
Diversion ratio                & 0.29      & 0.5       \\
Own-price elasticity of demand & 2         & 4         \\
Ratio of prices $p_2 / p_1$    & 1         & 1         \\
\bottomrule
\end{tabular*}

\medskip

\raggedright
Profitability calculation:\\[\medskipamount]
$\begin{alignedat}{2}
\frac{p_1 - c_1}{p_1} &\overset{?}{\leqslant} 
  \frac{1}{\eta_{11}(p_1,p_2.\dots,p_J)} + \frac{p_2 - c_2}{p_2} \frac{p_2}{p_1} DR_{12},
  &\qquad& 0.1 \leqslant \frac{1}{2} + 0.2 \times 1 \times 0.29 = 0.56
\\
\frac{p_2 - c_2}{p_1} &\overset{?}{\leqslant} 
  \frac{1}{\eta_{22}(p_1,p_2.\dots,p_J)} + \frac{p_1 - c_1}{p_1} \frac{p_1}{p_2} DR_{21},
  &\qquad& 0.2 \leqslant \frac{1}{4} + 0.1 \times 1 \times 0.5 = 0.30
\end{alignedat}$

\end{table}

\end{document}

Instead of boldrule I used booktabs. Adjust the amount of spacing before the first column and after the last one; but my advice is not to artificially expand tables, particularly if they contain such small amount of columns.

Note that \ldots should be \dots.

enter image description here

  • Thank you @egreg, I deleted my old comment since the package download works now. Your solution is perfect! I have a question though: My reasoning for wanting to make the table \textwidth is that the notes below it make it almost as wide as the text anyways. So, instead of leaving some space on the left and right, I thought I will rather make it as wide as the text to make it better looking. Since you say this is wrong however, how can I make it only as wide as is necessary? I tried to remove the \textwidth, but then am faced with "Illegal unit of measure" . – Malganas Feb 3 '17 at 11:36
3

Here is a solution, with the flushleft option for tablenotes, and the fleqn environment from nccmath to wrap the align*environment, which has the effect to use the | fleqnoption fromamsmath` locally, for one group of equations.

I also replaced the obsolete times package with newtx, which uses a Times clone (TeX Gyre Termes).

\documentclass[12pt]{article}
\usepackage{setspace,amsmath,graphicx,float}
\usepackage[english]{babel}
\usepackage{boldline}
\usepackage{array}
\usepackage[left=3cm,top=3.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\usepackage{newtxtext, newtxmath}
\usepackage{threeparttable}
\usepackage[margin=1cm]{caption}
\usepackage{amssymb}
\usepackage{tabularx}
\usepackage{nccmath}


 \begin{document}

\begin{table}[H]
  \centering
  \small
  \caption[xxx]{Example calculation for a two-product SSNIP test.}% \citep{QuantTech}
  \begin{threeparttable}
    \begin{tabularx}{\textwidth}{p{20em} >{\centering\arraybackslash}p{8em} >{\centering\arraybackslash}p{7em}}
      \hlineB{3}
                                     & Product 1 & Product 2 \\ \hline
      Margin & 10\,\% & 20\,\% \\
      Diversion ratio & 0.29 & 0.5 \\
      Own-price elasticity of demand & 2 & 4 \\
      Ratio of prices $p_2/p_1 $ & 1 & 1 \\
      \hlineB{3}
    \end{tabularx}
    \begin{tablenotes}[flushleft]
      \setlength{\belowdisplayskip}{0pt} \setlength{\belowdisplayshortskip}{0pt}
      \setlength{\abovedisplayskip}{0pt} \setlength{\abovedisplayshortskip}{0pt}
      \item Profitability calculation:
      \begin{fleqn}[\fontdimen2\font]
        \begin{align*}
          \frac{p_1 - c_1}{p_1} & \overset{?}{\leqslant} \frac{1}{\eta_{11}(p_1,p_2.\ldots,p_J)} + \frac{p_2 - c_2}{p_2} \frac{p_2}{p_1} DR_{12}, & 0.1 & \leqslant \frac{1}{2} + 0.2 × 1 × 0.29 = 0.56 \\%
          \frac{p_2 - c_2}{p_1} & \overset{?}{\leqslant} \frac{1}{\eta_{22}(p_1,p_2.\ldots,p_J)} + \frac{p_1 - c_1}{p_1} \frac{p_1}{p_2} DR_{21}, & 0.2 & \leqslant \frac{1}{4} + 0.1 × 1 × 0.5 = 0.30
        \end{align*}
      \end{fleqn}
    \end{tablenotes}
  \end{threeparttable}
  \label{ExampleSSNIP}
\end{table}

\end{document} 

enter image description here

However I suggest this code, based on tabulary, which looks niver in my opinio:

\documentclass[12pt]{article}
\usepackage{setspace,amsmath,graphicx,float}
\usepackage[english]{babel}
\usepackage{boldline}
\usepackage{array}
\usepackage[left=3cm,top=3.5cm,right=2.5cm,bottom=2.5cm]{geometry}
\usepackage{newtxtext, newtxmath}
\usepackage{threeparttable}
\usepackage[margin=1cm]{caption}
\usepackage{amssymb}
\usepackage{tabularx, tabulary}
\usepackage{nccmath}


 \begin{document}

\begin{table}[H]
  \centering
  \small\setlength\extrarowheight{2pt}
  \caption[xxx]{Example calculation for a two-product SSNIP test.}% \citep{QuantTech}
  \begin{threeparttable}
    \begin{tabulary}{\textwidth}{L>{\centering\arraybackslash}p{8em} >{\centering\arraybackslash}p{8em}@{}}%p{20em} \hlineB{3}
                                     & Product 1 & Product 2 \\ \hlineB{3}
      Margin & 10\,\% & 20\,\% \\
      Diversion ratio & 0.29 & 0.5 \\
      Own-price elasticity of demand & 2 & 4 \\
      Ratio of prices $p_2 / p_1$ & 1 & 1 \\
      \hlineB{3}
    \end{tabulary}
    \begin{tablenotes}[flushleft]\footnotesize
      \setlength{\belowdisplayskip}{0pt} \setlength{\belowdisplayshortskip}{0pt}
      \setlength{\abovedisplayskip}{0pt} \setlength{\abovedisplayshortskip}{0pt}
      \item Profitability calculation:
      \begin{fleqn}[\fontdimen2\font]
        \begin{align*}
          \frac{p_1 - c_1}{p_1} & \overset{?}{\leqslant} \frac{1}{\eta_{11}(p_1,p_2.\ldots,p_J)} + \frac{p_2 - c_2}{p_2} \frac{p_2}{p_1} DR_{12}, & 0.1 & \leqslant \frac{1}{2} + 0.2 \times 1 \times 0.29 = 0.56 \\%
          \frac{p_2 - c_2}{p_1} & \overset{?}{\leqslant} \frac{1}{\eta_{22}(p_1,p_2.\ldots,p_J)} + \frac{p_1 - c_1}{p_1} \frac{p_1}{p_2} DR_{21}, & 0.2 & \leqslant \frac{1}{4} + 0.1 \times 1 \times 0.5 = 0.30
        \end{align*}
      \end{fleqn}
    \end{tablenotes}
  \end{threeparttable}
  \label{ExampleSSNIP}
\end{table}

\end{document} 

enter image description here

  • Thank you a lot for the solution and also the corrections! What is the point of [\fontdimen2\font] though? From what I saw, it doesn't do anything. Going back to my first question: How can I move the first column (not the notes below it!) to the right? Ideally, I would want to treat the three columns as group, so that as a whole the three columns lie at the center of the table. I can provide an example from the original source if needed. – Malganas Feb 2 '17 at 19:53
  • 1
    \fontdimen2\font is the interword space in the current font. I had to use it because although \item in table notes is empty, there is nonetheless this space in front of ‘Profitability’, so I had to put it as a display indent via the optional argument of the fleqn environment, to ensure vertical alignment. As to your first requirement, one might reduce the width of the first column, but I'm not not sure I fully understand. It would be clearer, I guess, with an example. – Bernard Feb 2 '17 at 20:38

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.