formula in Latex table to implement line wrapping method
simple Two-step walk:
- 1. First place the following statement in the introductory area of the Latex body:
\newcommand{\tabincell}[2]{\begin{tabular}{@{}#[email protected]{}} #2 \end{tabular} }% placed in the introductory area
- 2. Then insert the contents in the grid inside the tabular using \tabincell{c}{} , and you can wrap the text in the table automatically
Here is an example that can be saved directly as a. tex file compilation run: \documentclass[a4paper,12pt]{article}
\begin{document}%-------------------------------------------------------------------------------------------------
\begin{table}
\newcommand{\tabincell}[2]{\begin{tabular}{@{}#[email protected]{}} #2 \end{tabular}}% introductory area
\centering\begin{tabular}{|c|c|c|}\hline
1 & \tabincell{c}{the first line \ \ The next\\the next\\ last}
& \ Tabincell{c}{one \ \ One}\% newline, each element inside the cell is \tabincell{c}{with the table contents}\hline
2
& \tabincell{c}{hello\\ aha\\ ok \\yes \\en}
& \ Tabincell{c}{two \ \ "\" \ "\ \" \ \\hline
\end{tabular}%--------------------------------------------------------------------------------------------------
\caption{longtitle}
\end{table}\end{document} results such as:
Formula wrapping method in Latex table