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.

I'm getting really frustrated. I want to enter the following table into my LaTeX document, but the first and third columns refuse to narrow so it is too wide. Can someone please tell me what I am doing wrong? If I can format it properly the table should fit to about half a page width. Thanks for any help.

\begin{table}
\begin{tabular}{|c p{3cm}|c p{2cm}|c p{5cm}|c p{2cm}|}
\hline
 & Gene & Protein & Disease \\
\hline
\multirow{3}{*}{Soluble lysozomal enzyme deficiencies} & CLN10 (CTSD)  & Cathepsin D & Congenital*, LINCL, JNCL, ANCL \\
& CLN1 & Palmitoyl protein thioesterase 1 (PPT1) & INCL*, LINCL, JNCL, ANCL \\
& CLN2 & Tripeptidyl peptidase 1 (TPP1) & LINCL, JNCL \\
\multirow{5}{*}{Non-enzyme deficiencies} & CLN3 & Transmembrane protein & JNCL* \\
& CLN5 & Soluble; lysosomal & LINCL, JNCL, ANCL \\
& CLN6 & Transmembrane protein; ER & LINCL, ANCL Kuf's Type A \\
& CLN7 (MSFD8) & Transmembrane protein; Endolysosomal transporter & LINCL \\
& CLN8 & Transmembrane protein; ER & LINCL \\
\hline
\end{tabular}
\caption{Classification of NCLs by CLN gene affected \cite{haltia} \\ *indicates main form of NCL associated with the gene}
\label{table1}
\end{table}
share|improve this question
add comment

migrated from stackoverflow.com May 31 '12 at 6:56

This question came from our site for professional and enthusiast programmers.

2 Answers

The traditional left, centre and right aligned columns do not wrap. You should use a paragraph column in order to allow/force wrapping (or another package that allows additional column types, like tabularx's X-column, say).

The following modification to your table uses

  • tabularx to have adjustable width columns (X types) to fit within the remainder of \textwidth;
  • geometry to allow for more room on your page;
  • column formatting using the >{...} directive, supplied by the array package (loaded by tabularx).

enter image description here

\documentclass{article}
\usepackage[margin=15mm]{geometry}% http://ctan.org/pkg/geometry
\usepackage{multirow}% http://ctan.org/pkg/multirow
\usepackage{tabularx}% http://ctan.org/pkg/tabularx
\begin{document}
\begin{table}
  \begin{tabularx}
      {\textwidth}
      {|X p{3cm}|>{\raggedright\arraybackslash}X >{\raggedright\arraybackslash}p{2cm}|}
    \hline
     & Gene & Protein & Disease \\
    \hline
    \multirow{3}{*}{Soluble lysozomal enzyme deficiencies} & CLN10 (CTSD)  & Cathepsin D & Congenital*, LINCL, JNCL, ANCL \\
     & CLN1 & Palmitoyl protein thioesterase 1 (PPT1) & INCL*, LINCL, JNCL, ANCL \\
     & CLN2 & Tripeptidyl peptidase 1 (TPP1) & LINCL, JNCL \\
    \multirow{5}{*}{Non-enzyme deficiencies} & CLN3 & Transmembrane protein & JNCL* \\
     & CLN5 & Soluble; lysosomal & LINCL, JNCL, ANCL \\
     & CLN6 & Transmembrane protein; ER & LINCL, ANCL Kuf's Type A \\
     & CLN7 (MSFD8) & Transmembrane protein; Endolysosomal transporter & LINCL \\
     & CLN8 & Transmembrane protein; ER & LINCL \\
    \hline
  \end{tabularx}
  \caption{Classification of NCLs by CLN gene affected indicates main form of NCL associated with the gene}
  \label{table1}
\end{table}
\end{document}

Since I'm unfamiliar with the exact usage/context, you may need to adjust your \multirow specification.

share|improve this answer
add comment

I recommend the tabu* package for easy control of variable-width columns. In the definition X[4,l] which I have chosen for your first column, the relative width of the column is 4 (i.e. it is twice as wide as the second column), and cell alignment is left**. You can adjust the table width as desired by replacing to \textwidth with e.g. to 10cm.

In addition, I've inserted the tabular into a ThreePartTable environment to allow for table notes (footnotes), and increased \arraystretch to achieve a more pleasant line spacing. You might want to consider the booktabs package for additional style recommendations.

enter image description here

\documentclass{article}
\usepackage{tabu}
\usepackage{threeparttablex}
\renewcommand{\arraystretch}{1.5}

\begin{document}

\begin{table}
\begin{ThreePartTable}
\begin{tabu} to \textwidth {|   X[4,l] 
                                X[2,l] 
                                X[3,l]<{\strut} 
                                X[3,l]<{\strut}
                            |}
    \hline
     & Gene & Protein & Disease \\
    \hline
    Soluble lysozomal enzyme deficiencies & CLN10 (CTSD)  & Cathepsin D & Congenital\tnote{*}, LINCL, JNCL, ANCL \\
     & CLN1 & Palmitoyl protein thioesterase 1 (PPT1) & INCL\tnote{*}, LINCL, JNCL, ANCL \\
     & CLN2 & Tripeptidyl peptidase 1 (TPP1) & LINCL, JNCL \\\hline
    Non-enzyme deficiencies & CLN3 & Transmembrane protein & JNCL\tnote{*} \\
     & CLN5 & Soluble; lysosomal & LINCL, JNCL, ANCL \\
     & CLN6 & Transmembrane protein; ER & LINCL, ANCL Kuf's Type A \\
     & CLN7 (MSFD8) & Transmembrane protein; Endolysosomal transporter & LINCL \\
     & CLN8 & Transmembrane protein; ER & LINCL \\
    \hline
\end{tabu}
\begin{tablenotes}
    \item[*] indicates main form of NCL associated with the gene
\end{tablenotes}
\caption{Classification of NCLs by CLN gene affected}
\label{table1}
\end{ThreePartTable}
\end{table} 

\end{document}

*According to my knowledge, you cannot use \multirow with tabu, however if my answer is close to what you want to achieve, that doesn't seem to be a restriction.

**A\strut needs to be inserted in columns that contain cells determining the row height to prevent incorrect spacing.

share|improve this answer
    
In my opinion there is rarely need for \multirow; I'd say that shifting down the entries in the first column of this table hinders its readability, rather than enhancing it. –  egreg May 31 '12 at 10:03
    
Concerning the readability of vertically ill-aligned cells, I completely agree. A (vertically top-aligned) \multirow or possibly an alternative means of row spanning would in my opinion be adequate here if the first-column entries were sufficiently long to determine the first row's height. –  dgs May 31 '12 at 10:27
add comment

Your Answer

 
discard

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