Graphics, Figures & Tablesnewline in tables

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
jlillywh
Posts: 4
Joined: Fri Jun 12, 2009 10:24 pm

newline in tables

Post by jlillywh »

I have a row in a table that is too long and want to put the text in
the row to a new line. According to the documentation, it says to
insert TeX command
\linebreak

I did that and saw no result in the pdf or DVI

I also read that you can do

\newline

I got nothing on that as well.

Am I doing something wrong?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

newline in tables

Post by localghost »

jlillywh wrote:[...] According to the documentation, it says to insert TeX command
\linebreak [...]
Please give a link to the documentation that told you so. Show us the concerning table by means of a minimal working example (MWE) and explain exactly what you want to achieve.


Best regards and welcome to the board
Thorsten
jlillywh
Posts: 4
Joined: Fri Jun 12, 2009 10:24 pm

newline in tables

Post by jlillywh »

I was told about the \linebreak command here:
http://wiki.lyx.org/LyX/Tables#toc4
under the heading 'multiple lines in one cell'

below is my sample file where I can't get \linebreak to work:

Code: Select all

Code, edit and compile here:
%% LyX 1.6.3 created this file. For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}
\makeatother
\usepackage{babel}
\begin{document}
Here is a table where the \textbackslash{}linebreak is not working.
It should start a new line after the word {}``jumps.''
%
\begin{table}[h]
\caption{my table}
\begin{tabular}{|c|c|}
\hline
x & y\tabularnewline
\hline
\hline
the brown cow jumps\linebreak over the moon & the dog barks\tabularnewline
\hline
stuff & stuff\tabularnewline
\hline
\end{tabular}
\end{table}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

newline in tables

Post by localghost »

Doesn't work for me either. The tabular environment offers several other column types which allow line breaks. Just follow the link. You may use packages like array or tabularx. But don't ask me how to include them in LyX.
wintermute
Posts: 1
Joined: Sun Jun 21, 2009 6:12 pm

Re: newline in tables

Post by wintermute »

localghost mentioned some stuff that i should probably check out, but so far when I've needed something like this I've used a parbox or a minipage inside the table to achieve it.
To do this in LyX, click the Insert TeX Code button then write either \parbox{<width>}{<Text goes here>} or \begin{minipage}{<width>}<text goes here>\end{minipage}.

Widths are standard latex stuff e.g. 1in for one inch, 1cm for 1 cm and so on (or you could use the units ex or em to get widths that vary according to the current font size).

EDIT: Oh, I forgot to mention one thing, this way of getting linebreaks inside a cell tend to cause the space between the stuff in the parbox/minipage and the rows above and beneath to be a bit too small. In a "normal" latex editor I'd just add a bit of extra space to the linebreaks between table rows but I don't know if that's possible in LyX. A possible workaround is to put a strut at the beginning of the text in the parbox/minipage with e.g. \rule{0pt}{1.1\baselineskip} and a bit of space at the end with e.g. \vspace{1ex}.
Post Reply