Wrap Long Table Cells
Tutorial
LaTeX lays a table out from a column specification, and the l column it is usually given is as wide as its widest line and never wraps. The shipped TableBlock template writes one l per column, so a cell holding a paragraph runs off the right edge of the page. The cure is to declare that one column as a fixed-width paragraph column, which is a decision per table rather than per wiki: this tutorial gives the offending table a template of its own and leaves every other table alone.
- Start from a table with one long cell. Any table does, as long as one cell holds more text than fits across the page.
|cell 1|cell 2|Le Lorem Ipsum est simplement du faux texte employé dans la composition et la mise en page avant impression. Le Lorem Ipsum est le faux texte standard de l'imprimerie depuis les années 1500. |cell 3|cell 4|cell 5Exported as it stands, it becomes a tabular whose three columns are all l, and the third one is the problem.
\begin{tabular}{|l|l|l|} - Write a template that changes the column specification and nothing else. Load the shipped TableBlock, replace its reference to $tableSpec with a specification of your own, and render what comes back — the four-step override strategy. p{0.6\linewidth} is the third column: a paragraph column 0.6 of the text width wide, whose content wraps. Replacing the reference rather than the line that computes it is the shorter edit, and it keeps everything else the template does, down to the blank lines that separate the table from the block above it.
## Step 1: get the default template being overridden #set ($template = $latex.processor.getTemplate('default/TableBlock')) ## Step 2: compute the new content #set ($newContent = $stringtool.replace($template.content.content, '${tableSpec}', '|l|l|p{0.6\linewidth}|')) ## Step 3: set the new content #set ($discard = $template.content.setContent($newContent)) ## Step 4: render the modified template $latex.processor.render($template)##The specification is plain LaTeX, so the other column types are worth knowing: the wikibooks page on text wrapping in tables lists them.
- Install it under the path latex/CustomTableBlock, the same way as any other override. Nothing changes yet: CustomTableBlock is not the name of a Block class, so no table asks for it.
- Point the offending table at it, with the latex-template parameter on the line above the table.
(% latex-template="CustomTableBlock" %) |cell 1|cell 2|Le Lorem Ipsum est simplement du faux texte employé dans la composition et la mise en page avant impression. Le Lorem Ipsum est le faux texte standard de l'imprimerie depuis les années 1500. |cell 3|cell 4|cell 5That table, and only that table, is now written by your template.
\begin{center} \begin{tabular}{|l|l|p{0.6\linewidth}|} \hline cell 1 & cell 2 & Le Lorem Ipsum est simplement du faux texte employé dans la composition et la mise en page avant impression. Le Lorem Ipsum est le faux texte standard de l'imprimerie depuis les années 1500.\\ \hline cell 3 & cell 4 & cell 5\\ \hline \end{tabular} \end{center}Compiled, the difference is the whole point of the exercise. Before, the long cell walked off the page:

After, it wraps inside its column:

FAQ
Why not change the shipped TableBlock template instead?
Because a column specification is a statement about one table's contents. An override installed as latex/TableBlock applies to every table in every export, and the tables that were fine become 0.6 of the text width whether they need it or not. The latex-template parameter exists so that a layout decision can be scoped to the table that needs it.
My table does not have three columns.
Then the specification does not fit it: |l|l|p{0.6\linewidth}| describes three columns, and LaTeX fails to compile a row with a different number of cells. Write one template per table shape, or build the specification from $columnSize, which the shipped template computes just above the line you are replacing.
Can two tables on the same page wrap different columns?
Yes. Install one template per layout, under latex/CustomTableBlock and latex/WideFirstColumnBlock for instance, and give each table the parameter naming the one it wants.