Graphics, Figures & Tablesauto-size table width to make use of all space available

Information and discussion about graphics, figures & tables in LaTeX documents.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

auto-size table width to make use of all space available

Post by localghost »

That's something to work with. For better hyphenation I added the ragged2e package.

Code: Select all

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{array,booktabs,tabularx}
\usepackage{ragged2e}

\newcolumntype{C}{>{\Centering}X}
\newcolumntype{L}{>{\RaggedRight}X}
\newcolumntype{R}{>{\RaggedLeft}X}

\begin{document}
  \begin{table}[!ht]
    \caption{Comparison of \LaTeX-based or \LaTeX-supporting Equation Editors}\label{editor-comparison}
    \small
    \centering
    \begin{tabularx}{\linewidth}{*4{C}}\toprule
      Editor (Type) & Edited as & Previewed as & Inserted as \\ \midrule[1pt]
      LyX (Standalone) & WYSIWYG inline or button-facilitated mark-up & WYSIWYG inline & WYSIWYG inline \\\bottomrule
    \end{tabularx}
  \end{table}
\end{document}
For details about the other involved packages please refer to the according manuals.

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

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

Re: auto-size table width to make use of all space available

Post by ptrcao »

Excellent work. Thank you localghost; it appears to have done the trick. I'll have to read up on those packages as I've never used them before. At least I know now about defining new columns. :)
OS info: Win XP | Debian 6.0 | Ubuntu 10.04
Latex editor of choice: TexWorks (for dual view feature)
ptrcao
Posts: 88
Joined: Sun Dec 05, 2010 3:26 am

Re: auto-size table width to make use of all space available

Post by ptrcao »

Quick follow up: why did you use both "h" and "t" at the same time for the table positioning?
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

auto-size table width to make use of all space available

Post by localghost »

To restrict float placement to a single parameter is not good. You should at least give two of them. Note that the default setting for float placement is »htp«, determined by the so called float placement specifier (fps). There are several additional conditions which are overridden by the exclamation mark. I answered this similar in another topic [1]. If you have access to the mentioned book it's worth to study the relevant parts.

[1] View topic: Caption and PSTricks
Post Reply