0

I currently use the tabular package to create my table. One of my columns has several lines of text, so I need a line break mechanism. I do currently have a working mechanism.

\usepackage{makecell}
...
\begin{center}
    \begin{tabular}{ |c|c|c|c|c| }
        \hline
        \textbf{Name} & \textbf{Goal} & \textbf{Results} & \textbf{Methods used} & \textbf{Validity} \\
        \hline
        VS Code       & \makecell[l]{Desktop-\acs{IDE} with plugin\\mechanism and language server\\integration \cite{vscode01, vscode02}.} & ? & ? & ? \\
        \hline
        Cloud9 IDE    & \makecell[l]{Cloud-based \acs{IDE} with real time\\team collaboration capabilities with\\a computation and storage based\\pricing system \cite{cloud-ide02, cloud9ide01}.} & ? & ? & ? \\
        \hline
    \end{tabular}
\end{center}

The annoying thing is that I manually have to do the line break. So if I change the text somewhere in the middle, I have to readjust everything. What would be much better is a function like \makecell{...} that automatically does its line break as needed.

Is there a function somewhere in Latex for automatic line break?

  • \makecell allows for line breaks, but they have to be hand-done. – Bernard Apr 19 '18 at 20:52
1

There are multiple methods to get automatic line breaks

  • use columns of a fixed with, e.g. p{1cm}
  • use the tabularx package and X columns which will automatically choose column widths to fill the desired width for the whole table

Furthermore I suggest to use the booktabs package for a nice table layout.

\documentclass{article}

\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{array}


\begin{document}

\begin{center}
    \begin{tabularx}{\linewidth}{@{}p{1.2cm}Xc>{\centering\arraybackslash}p{1.6cm}c@{}}
        \toprule
        \textbf{Name} & \textbf{Goal} & \textbf{Results} & \textbf{Methods used} & \textbf{Validity} \\
      \midrule
      VS Code  & Desktop-IDE with plugin mechanism and language server integration. & ? & ? & ? \\
      \addlinespace
            Cloud9 IDE & Cloud-based IDE with real time team collaboration capabilities with a computation and storage based pricing system. & ? & ? & ? \\
      \bottomrule
    \end{tabularx}
\end{center}

\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.