Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Background

Using booktabs produces the top table in the following image:

enter image description here

Both tables reside in floats, but even when outside of the float the same result is produced. The Application and Version columns are too wide.

LyX seems to generate the following LaTeX code:

\begin{tabular}{>{\raggedright}p{4.5cm}>{\raggedright}p{4.5cm}>{\raggedright}p{4.5cm}l}

The preamble is straightforward:

\hypersetup{
    colorlinks=false,
    pdfborder={0 0 0},
}

\usepackage{flafter}
\usepackage{colortbl}
\usepackage{booktabs}

The commands \toprule() and \\\midrule % and \\\bottomrule % are applied directly to the table.

Questions

  1. Without hand-massaging each table, how can the columns be made to auto-fit? (I could not find how to control column width in the booktabs documentation.)
  2. How can the top-, mid-, and bottom-rules be applied across all tables in the document, automatically?

Thank you!

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted
  1. Change the Preamble to the following:

    \usepackage{graphicx}
    \usepackage{booktabs}
    \usepackage[dvipsnames,svgnames,x11names,hyperref,table]{xcolor}

    % Table colours \colorlet{tableheader}{LightGray!80} \colorlet{zebra}{LightGray!40}

    \hypersetup{ colorlinks=false, pdfborder={0 0 0}, }

    \let\originaltable\table \let\endoriginaltable\endtable \renewenvironment{table}[1][ht]{% \originaltable[#1] \centering}% {\endoriginaltable}

  2. In the settings for each column, ensure the Width is blank. (Any numeric value will attempt to fit the columns to that width.)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.