Graphics, Figures & TablesLine break within a table cell

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
ptrcao
Posts: 88
Joined: Sun Dec 05, 2010 3:26 am

Line break within a table cell

Post by ptrcao »

I can't just use "\\" within a table cell, but I want to start a new line. What can I do to achieve this?
Last edited by ptrcao on Sun Apr 03, 2011 1:01 pm, edited 1 time in total.
OS info: Win XP | Debian 6.0 | Ubuntu 10.04
Latex editor of choice: TexWorks (for dual view feature)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Line break within a table cell

Post by localghost »

Get familiar with the features of a standard tabular environment. If your own efforts come to nothing, provide a minimal example that shows the problem(s) clearly. Emphasize is on minimal content. The example has to be compilable as provided.


Thorsten
ptrcao
Posts: 88
Joined: Sun Dec 05, 2010 3:26 am

Line break within a table cell

Post by ptrcao »

localghost wrote:Get familiar with the features of a standard tabular environment. If your own efforts come to nothing, provide a minimal example that shows the problem(s) clearly [1]. Emphasize is on minimal content. The example has to be compilable as provided.
Thorsten
In the below minimal example, I want to line break before the new sentence starting with "Presence of lactose...":

Code: Select all

\documentclass[12pt]{article}

\usepackage{fullpage}
\usepackage{booktabs}
\usepackage{tabularx}

\begin{document}

\begin{table}[h!]
\begin{tabularx}{1 \linewidth}{X X X X}
\toprule
Media & Characteristics & Uses/limitations \\
\cmidrule(r){1-1}  \cmidrule(l r){2-2} \cmidrule(l){3-3}
MacConkey agar & The selective components in MAC are bile salts and crystal violet, which inhibit the growth of gram-positive bacteria. Presence of lactose and neutral red (a pH indicator) will confirm a gram-negative bacteria that uses lactose as a carbon and energy source.  Release of acidic products changes colony colour to red.  & Used as a form of selective and differential media to contrast types of gram-negative bacteria that use lactose vs. those that don't.\\
\bottomrule
\end{tabularx}
\end{table}

\end{document}
OS info: Win XP | Debian 6.0 | Ubuntu 10.04
Latex editor of choice: TexWorks (for dual view feature)
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Line break within a table cell

Post by localghost »

Just begin a new paragraph at the appropriate place.

Code: Select all

… of gram-positive bacteria.\par Presence of lactose …
ptrcao
Posts: 88
Joined: Sun Dec 05, 2010 3:26 am

Line break within a table cell

Post by ptrcao »

localghost wrote:Just begin a new paragraph at the appropriate place.

Code: Select all

… of gram-positive bacteria.\par Presence of lactose …
Great, that's progress. I still want an actual line skip between the paragraphs, I've tried \newline but that doesn't work. Do you know how I can get a line skip? Thanks.
OS info: Win XP | Debian 6.0 | Ubuntu 10.04
Latex editor of choice: TexWorks (for dual view feature)
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Line break within a table cell

Post by localghost »

Then just insert a skip.

Code: Select all

… of gram-positive bacteria.\par\medskip Presence of lactose …
ptrcao
Posts: 88
Joined: Sun Dec 05, 2010 3:26 am

Line break within a table cell

Post by ptrcao »

localghost wrote:Then just insert a skip.

Code: Select all

… of gram-positive bacteria.\par\medskip Presence of lactose …
Thanks localghost. That's good. And just to reinforce the fact that this is a following, not a leading paragraph, is there a way to make it indent a little?
OS info: Win XP | Debian 6.0 | Ubuntu 10.04
Latex editor of choice: TexWorks (for dual view feature)
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Line break within a table cell

Post by localghost »

You should decide either for a skip or an indentation. A combination is typographical nonsense. But if you insist, just insert some additional horizontal space (\indent doesn't work here).

Code: Select all

… of gram-positive bacteria.\par\medskip\hspace*{3pt} Presence of lactose …
ptrcao
Posts: 88
Joined: Sun Dec 05, 2010 3:26 am

Line break within a table cell

Post by ptrcao »

To revisit an old problem. Why can't the suggested solution work for this? Look out for the \par\medskip below (on the row starting with "MSA" and notice it does not achieve the desired new paragraph and lineskip. Thanks.

Code: Select all

\documentclass{article}
\usepackage{booktabs}


\begin{document}

\begin{figure*}

\small{
\begin{center}
\begin{tabular}{@{} l c c @{}}
\toprule
Characteristic & \multicolumn{2}{c}{Result}\\
 \cmidrule{2-3}
 & Seaweed isolate & Coral isolate \\
 \midrule
Cell shape & Rod & Rod\\
Gram stain & $-$ & $-$\\
Oxidase & $+$ & $-$\\
Catalase & $+$ & $-$\\
Anaerobic & Growth (weak) & No growth\\
Motility & $+$ & $-$ or ? \\
Indole production & $+$ & $-$ or ? \\
Hugh \& Leifsons & ? & ? \\
MSA \par\medskip Growth \par\medskip Mannitol utilisation & Growth & No growth\\
%Growth in absence of salt & & \\ (Didn't get time to do this one.)
Colony pigmentation & White & White \\
Colony texture & Smooth, creamy & Waxy, pellet-like \\
Colony edges & Entire & Entire \\
Colony shape & Round & Round \\
Colony elevation & Flat & Buldge\\
Medium modifications & Cracked patterns & Clear halo, pits, liquification\\
\bottomrule
\end{tabular}
\end{center}
}
\end{figure*} 


\end{document}
OS info: Win XP | Debian 6.0 | Ubuntu 10.04
Latex editor of choice: TexWorks (for dual view feature)
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Line break within a table cell

Post by localghost »

ptrcao wrote:[…] Why can't the suggested solution work for this? […]
The chosen column types don't allow line breaks or paragraphs, respectively.
Post Reply