1

I have a long mathematical expression within parenthesis which is larger than the column width that I have specified for my table. How do I force it to break the expression onto a new line?

       \begin{center}
       \footnotesize
       \begin{longtable}[l]{>{\raggedright}p{2.25cm}>{\raggedright}p{9cm}>{\raggedright\arraybackslash}p{3cm}}
       \hline
       \textbf{Text}  &     \textbf{Maths} &     \textbf{Text} \\ \hline
       \endfirsthead
        \multicolumn{3}{c}{{\bfseries \tablename\ \thetable{} -- Continued from previous page}} \\
          \hline
                     \textbf{Text}  &     \textbf{Maths} &     \textbf{Text} \\ \hline
           \endhead
            \multicolumn{3}{r}{{-- Continued on next page}} \\
           \endfoot
          \endlastfoot
  TEXT 1 &  $\dfrac{\kappa_{nf}}{\kappa_{f}}= 1+3\left(\dfrac{\dfrac{\kappa_{p}}{\kappa_{f}}-1}{\dfrac{\kappa_{p}}{\kappa_{f}}+2}\right)\phi+ \left(3\left(\dfrac{\dfrac{\kappa_{p}}{\kappa_{f}}-1}{\dfrac{\kappa_{p}}{\kappa_{f}}+2}\right)^{2}+\dfrac{3}{4}\left(\dfrac{\dfrac{\kappa_{p}}{\kappa_{f}}-1}{\dfrac{\kappa_{p}}{\kappa_{f}}+2}\right)^{2}+ \newline \dfrac{9}{16}\left(\dfrac{\dfrac{\kappa_{p}}{\kappa_{f}}-1}{\dfrac{\kappa_{p}}{\kappa_{f}}+2}\right)^{3}\left(\dfrac{\dfrac{\kappa_{p}}{\kappa_{f}}+2}{\dfrac{\kappa_{p}}{2\kappa_{f}}+3}\right)....\right)\phi^{2}$ & Text 2\\

      \hline
      \end{longtable}
      \end{center}
      \normalsize

Ideally I would like the break to occur at the just before the \dfrac{9}{16}

I have tried putting a \begin{split} and \end{split} but I get a latex error (Package amsmath Error: \begin{split} won't work here

Has anyone got an idea?

Cheers

  • center has no effect on a longtable, other than introduce vertical space. – David Carlisle Oct 1 '14 at 11:24
3

You can't break a line inside \left...\right, so write \right.\newline\left., where the dot means "invisible delimiter".

By the way, breaking at 3/4 gives a better-looking result.
Personal opinion: I prefer operators be tied to the right operand, so instead of having + signs at the end of line, I'd rather like to place them at the beginning, correctly aligned.

\documentclass[a4paper,10pt,draft]{article}
\usepackage[cm]{fullpage}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{longtable,array}
\newcolumntype{P}[1]{>{\raggedright\arraybackslash}p{#1}}

\begin{document}
\begin{longtable}{P{2.25cm}P{9cm}P{3cm}}
\hline
\textbf{Text}  &     \textbf{Maths} &     \textbf{Text} \\
\hline
\endfirsthead
\multicolumn{3}{c}{{\bfseries \tablename\ \thetable{} -- Continued from previous page}} \\
\hline
\textbf{Text}  &     \textbf{Maths} &     \textbf{Text} \\ \hline
\endhead
\multicolumn{3}{r}{{-- Continued on next page}} \\
\endfoot
\endlastfoot
TEXT 1 &  $\dfrac{\kappa_{nf}}{\kappa_{f}}
          = 1 +
          3\left(\dfrac{\dfrac{\kappa_{p}}{\kappa_{f}}-1}{\dfrac{\kappa_{p}}{\kappa_{f}}+2}\right)\phi +
           \left(3\left(\dfrac{\dfrac{\kappa_{p}}{\kappa_{f}}-1}{\dfrac{\kappa_{p}}{\kappa_{f}}+2}\right)^{2}+\right.\newline
\left.     \dfrac{3}{4}\left(\dfrac{\dfrac{\kappa_{p}}{\kappa_{f}}-1}{\dfrac{\kappa_{p}}{\kappa_{f}}+2}\right)^{2} +
           \dfrac{9}{16}\left(\dfrac{\dfrac{\kappa_{p}}{\kappa_{f}}-1}{\dfrac{\kappa_{p}}{\kappa_{f}}+2}\right)^{3}
           \left(\dfrac{\dfrac{\kappa_{p}}{\kappa_{f}}+2}{\dfrac{\kappa_{p}}{2\kappa_{f}}+3}\right)....\right)\phi^{2}$ & Text 2\\

\hline
\end{longtable}
\end{document}
  • Presto! Cheers dude! Can the same be done with a long fraction? – Magiclamarshmallow Oct 1 '14 at 14:58
  • Explain better. Placing \newlines between objects is easy, but I think that break inside a fraction it's a very very bad idea, and gives a very poor result. – Astrinus Oct 1 '14 at 15:01
  • Like you say it gives a poor result so I think I will just break the fraction into two parts rather than try to split it over two line. Might need to do some algebra! – Magiclamarshmallow Oct 1 '14 at 16:21
2

A variant, using the nccmath package (for its mediumsized fractions) and the ltablex package, that allows for page breaking within tabularx environments. I use an aligned environment for the long math formula, and replace the \left … \right pairs with \Biggl … \Biggr. The makecell package allows to give some vertical spacing around the formula:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amssymb}
\usepackage{nccmath}
\usepackage[nomarginpar, showframe]{geometry}
\usepackage{mathtools}
\usepackage{array,ltablex}
\keepXColumns

\usepackage{makecell}
\setcellgapes{4pt}
\makegapedcells

\begin{document}

\setlength\tabcolsep{4pt}
\begin{tabularx}{\linewidth}{|>{\raggedright}p{2.25cm}| >{\footnotesize}X| >{\raggedright\arraybackslash}p{3cm}|}%
\hline
\textbf{Text} & \textbf{Maths} & \textbf{Text} \\ \hline
\endfirsthead
\multicolumn{3}{c}{{\bfseries \tablename\ \thetable{} -- Continued from previous page}} \\
\hline
\textbf{Text} & \textbf{Maths} & \textbf{Text} \\ \hline
\endhead
\multicolumn{3}{r}{{-- Continued on next page}} \\
\endfoot
\endlastfoot
TEXT 1 &
$ \begin{aligned}\MoveEqLeft[-1.5] \mfrac{κ_{nf}}{κ_{f}}= 1+3\Biggl(\mfrac{\mfrac{κ_{p}}{κ_{f}}-1}{\mfrac{κ_{p}}{κ_{f}}+2}\Biggr)ϕ + {}\\[-1ex]
& + \Biggl[3\Biggl(\mfrac{\mfrac{κ_{p}}{κ_{f}}-1}{\mfrac{κ_{p}}{κ_{f}}+2}\Biggr)^{\!2} + \mfrac{3}{4}\Biggl(\mfrac{\mfrac{κ_{p}}{κ_{f}}-1}{\mfrac{κ_{p}}{κ_{f}}+2}\Biggr)^{\!2}
+ \mfrac{9}{16}\Biggl(\mfrac{\mfrac{κ_{p}}{κ_{f}}-1}{\mfrac{κ_{p}}{κ_{f}}+2}\Biggr)^{\!3} \Biggl(\mfrac{\mfrac{κ_{p}}{κ_{f}}+2}{\mfrac{κ_{p}}{2κ_{f}}+3}\Biggr)....\Biggr]ϕ^{2}\end{aligned} $
& Text 2\\
\hline
\end{tabularx}

\end{document}

enter image description here

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.