4

I want the displayed equations to be centered in longtable, but it seems that they are shifted to the right a bit.

enter image description here

Here is the code.

\documentclass[a4paper, 11pt, oneside]{amsart}
\usepackage{amsmath,amssymb, amsthm}
\usepackage[a4paper,width=16.5cm,top=1.5cm,bottom=2.cm]{geometry}
\usepackage{ltxtable}
\usepackage{cases}
\usepackage{lipsum}

\begin{document}

\begin{longtable}{p{0.13\textwidth} | p{0.86\textwidth-2\tabcolsep}}
\hline\hline
\bf LEFT Col. & \bf RIGHT Col.\\
\hline\hline
ABC & \lipsum[2].\\
\hline
abc & \lipsum[2]
\begin{numcases}{u(r)=}
C_1 r + C_2 \log r + C_3 \log (\log r)  \\
 C_4 \log ( \log (\log r))+ C_5 \log (\log ( \log (\log r)))
\end{numcases}
hhu
\begin{align}
C_1 r + C_2 \log r + C_3 \log (\log r)+ C_4 \log ( \log (\log r))+ C_5 \log (\log ( \log (\log r)))
\end{align}
\\
\hline\hline
\end{longtable}

\end{document}

Besides, it seems that the table is too big. How to fix this?

6
  • 1
    Unrelated to your problem but: From the manual of the package: "[leqno] Left-side equation numbering (usually inherited from the \documentclass options). This looks silly with numbered cases!". I agree with that.
    – mickep
    May 29, 2022 at 7:44
  • 1
    @mickep - The amsart documentclass sets the leqno option.
    – Mico
    May 29, 2022 at 7:45
  • 1
    @Mico I know that (and I do not think that is a good idea, but that is another thing). The point in the manual is another if I interpret it correctly (I might be wrong): Adding equation numbers to the left, line by line, to a cases environment looks silly. That is what I agree with.
    – mickep
    May 29, 2022 at 7:50
  • 1
    @mickep -- Fair enough. (I happen to agree with you!)
    – Mico
    May 29, 2022 at 7:51
  • Coming back to the question, I also wonder if you really should use a table here. It could be better to use some kind of description environment or even subsections. As is, you leave a lot of white space in the left column and the text to the right looks cramped and "prisoned".
    – mickep
    May 30, 2022 at 5:53

2 Answers 2

4

The amsart document class would appear to execute some directives that ultimately mess with the equation-builder routines. See @egreg's answer for a full diagnosis and direct cure. If you don't pursue that solution route, it is necesssary to encase the displayed equations in a minipage.

Do also note that the usable width of the second column is not 0.86\textwidth-2\tabcolsep but, rather, 0.87\textwidth-4\tabcolsep-1\arrayrulewidth.

enter image description here

\documentclass[a4paper, 11pt, oneside]{amsart}
%\usepackage{amsmath,amssymb, amsthm} % loaded automatically by 'amsart' doc. class
\usepackage[a4paper,width=16.5cm,top=1.5cm,bottom=2.cm]{geometry}
\usepackage{longtable,cases,calc,lipsum}

\begin{document}

\begin{longtable}{p{0.13\textwidth} | p{0.87\textwidth-4\tabcolsep-1\arrayrulewidth}}
\hline
\bfseries LEFT Col. & \bfseries RIGHT Col.\\
\hline
abc & \lipsum[2][1-5] \par
\begin{minipage}{\hsize} % <-- new
\begin{numcases}{u(r)=}
C_1 r + C_2 \log r + C_3 \log (\log r)  \\
 C_4 \log ( \log (\log r))+ C_5 \log (\log ( \log (\log r)))
\end{numcases}
hhu
\begin{equation}
C_1 r + C_2 \log r + C_3 \log (\log r)+ C_4 \log ( \log (\log r))
  + C_5 \log (\log ( \log (\log r)))_{\vphantom{a}}
\end{equation}
\end{minipage} % <-- new
\\
\hline
\end{longtable}

\end{document}
3
  • This is what I am looking for. Thanks so much for the explanation and some useful suggestions :).
    – QA Ngô
    May 29, 2022 at 7:59
  • 3
    The cure might be good, but for the wrong disease. ;-) Don't blame David when it's not his fault! :-D
    – egreg
    May 29, 2022 at 20:29
  • @egreg - Good one! I've updated the answer so as not to cast unnecessary shade on David. :-) I've also included a pointer to your -- much more thorough -- diagnosis of the malady and direct cure.
    – Mico
    May 29, 2022 at 20:34
1

If you try it with article, the problem disappears, so it must depend on amsart and indeed this is so, because the class executes \fullwidthdisplay at every math display and this means

\displayindent=0pt \displaywidth=\columnwidth

In your context this will produce a larger width than allotted by the p column specification. You can solve the issue by telling LaTeX to use \linewidth instead.

\documentclass[a4paper, 11pt, oneside]{amsart}
\usepackage{amsmath,amssymb, amsthm}
\usepackage[a4paper,width=16.5cm,top=1.5cm,bottom=2.cm]{geometry}
\usepackage{longtable,array}
\usepackage{cases}
\usepackage{lipsum}

\newcommand{\modfullwidthdisplay}{%
  \displayindent=0pt
  \displaywidth=\linewidth
}
\newcolumntype{q}[1]{>{\let\fullwidthdisplay\modfullwidthdisplay}p{#1}}

\begin{document}

\begin{longtable}{
  @{}
  p{\dimexpr0.14\textwidth-\tabcolsep-0.5\arrayrulewidth}
  |
  q{\dimexpr0.86\textwidth-\tabcolsep-0.5\arrayrulewidth}
  @{}
}
\hline
\bfseries LEFT Col. & \bfseries RIGHT Col.\\
\hline
ABC & \lipsum[2].\\
\hline
abc & \lipsum[2]
\begin{numcases}{u(r)=}
C_1 r + C_2 \log r + C_3 \log (\log r)  \\
 C_4 \log ( \log (\log r))+ C_5 \log (\log ( \log (\log r)))
\end{numcases}
hhu
\begin{align}
C_1 r + C_2 \log r + C_3 \log (\log r)+ C_4 \log ( \log (\log r))+ C_5 \log (\log ( \log (\log r)))
\end{align}
\\
\hline
\end{longtable}

\end{document}

enter image description here

I changed a little the size specifications so as to cover the entire textwidth.

Please, note that \bf has been deprecated for about 30 years.

You must log in to answer this question.

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