Graphics, Figures & Tablesragged right in table columns but NOT in captions

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
tunamaccheese
Posts: 4
Joined: Sat Apr 24, 2010 6:57 pm

ragged right in table columns but NOT in captions

Post by tunamaccheese »

[Update -- Solved thanks to Thorsten's answer below. It requires the array package, which can be used to format specific columns of a table. Thanks Thorsten!]


Dear Community,

How can I make the formatting of all 'p' aligned columns in tables justified as 'ragged right', but keep the formatting of figure captions as 'fully justified'? Currently, the only way I know to format the table 'p' columns this way is by using the [raggedrightboxes] option of ragged2e. The problem is that this also makes my figure captions ragged right, and I would like the figures to be fully justified.

For example:

Code: Select all

\documentclass{article}
\usepackage[raggedrightboxes]{ragged2e} 
\usepackage{graphics}


\begin{document}


\begin{figure}
\caption{Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. }
\end{figure}


%borrowed this table from http://en.wikibooks.org/wiki/LaTeX/Tables
\begin{table}
\caption{This is the table caption.}
\begin{center}
    \begin{tabular}{ | l | l | l | p{5cm} |}
    \hline
    Day & Min Temp & Max Temp & Summary \\ \hline
    Monday & 11C & 22C & A clear day with lots of sunshine.  
    However, the strong breeze will bring down the temperatures. Adding extra text here to make the raggedness clear. \\ \hline
    Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells 
    across most of Scotland and Northern Ireland, 
    but rain reaching the far northwest. \\ \hline
    Wednesday & 10C & 21C & Rain will still linger for the morning. 
    Conditions will improve by early afternoon and continue 
    throughout the evening. \\
    \hline
    \end{tabular}
\end{center}
\end{table}

\end{document}
When I make a pdf from the LaTeX above, both the figure caption and the paragraph cells in the table are aligned as ragged right (flush left). I would like to have JUST the table cells aligned as flush left, and keep the figure caption as ragged right. Please let me know if this is unclear.

Thanks,
--Jordan
Last edited by tunamaccheese on Thu Apr 29, 2010 1:33 am, edited 1 time in total.

Recommended reading 2024:

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

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

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

ragged right in table columns but NOT in captions

Post by localghost »

The array package allows to declare new column types like shown below.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{array}
\usepackage{ragged2e}
\usepackage{blindtext}

\begin{document}
%  borrowed this table from http://en.wikibooks.org/wiki/LaTeX/Tables
  \begin{table}
    \caption{\blindtext}
    \centering
    \begin{tabular}{|l|l|l|>{\RaggedRight}p{5cm}|}\hline
      Day & Min Temp & Max Temp & Summary \\ \hline
      Monday & 11C & 22C & A clear day with lots of sunshine. 
      However, the strong breeze will bring down the temperatures. Adding extra text here to make the raggedness clear. \\ \hline
      Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells
      across most of Scotland and Northern Ireland,
      but rain reaching the far northwest. \\ \hline
      Wednesday & 10C & 21C & Rain will still linger for the morning.
      Conditions will improve by early afternoon and continue
      throughout the evening. \\ \hline
  \end{tabular}
\end{table}
\end{document}

Thorsten
Post Reply