Hot answers tagged

113 votes

Increase LaTeX table row height

Super Simple Solution I faced similar problem, & found a (not so conventional but) simple way to solve it. Wish, it will help others too. I had a table like this- \begin{tabular}{c|ccc} $x$ &...
Minhas Kamal's user avatar
  • 1,241
110 votes
Accepted

My table doesn't fit; what are my options?

Let's first identify what we're referring to when we use the term "table". The typical table environment is a float, and can contain anything: a paragraph of text, an image, or even a ...
Werner's user avatar
  • 588k
73 votes
Accepted

How to left align text in a table with \makecell

You just have to write \makecell[l]{…} if you want to left-align (it is vertically and horizontally centred by default). However, rather than using \resizebox I would suggest one of these two ...
Bernard's user avatar
  • 269k
56 votes

Adding space between columns in a table

If you need to adjust the spacing for just one table you could also add/remove some space before the table and restore previous value after it: \addtolength{\tabcolsep}{-1pt} \begin{tabular}{cc} ...
Pietro C's user avatar
  • 1,404
53 votes
Accepted

newline in multirow environment

There is several ways to do it. A very simple way is using \shortstack \documentclass{article} \usepackage[frenchb]{babel} \usepackage[T1]{fontenc} \usepackage{multirow} \begin{document} \begin{...
flav's user avatar
  • 4,594
49 votes

Table with multiple lines in some cells

Another possible solution — my preferred one in my use-cases so far as I wanted full control to what comes in which line while being as concise as possible — is using the makecell package, which would ...
Wolfone's user avatar
  • 591
48 votes

How to center the table in Latex

You can also use \begin{center} ... \end{center}. This works better with beamer for example because {\centering ... } messes with the size of the table for some reason. The new code would be: \begin{...
Walton's user avatar
  • 589
47 votes
Accepted

Tip on how to make a visually good table

I suggest you read the booktabs package documentation. Very good advices are given in there about table formatting and I think it is a good introduction on the subject. About your example, the ...
Jean-Sébastien's user avatar
46 votes
Accepted

Right alignment for p{length} box in tabular

Insert one of the commands \raggedright, \centering, or \raggedleft into the parbox depending on whether the paragraph should be typeset flush left, centered, or flush right. \documentclass{article} \...
gernot's user avatar
  • 47.1k
45 votes

The space between the table and its caption is very small

My attention was drawn to this question by another one that had been posted on TeX-LaTeX Meta. In spite of having been asked almost six years ago, not only—IMHO, of course!—is this question still ...
GuM's user avatar
  • 21.3k
45 votes

How does the \newcolumntype command work?

The array package documentation, on pages 2 and 3 has the explanations: Additional explanation To answer your specific question: \newcolumntype{Y}{>{\small\raggedright\arraybackslash}X} defines ...
Gonzalo Medina's user avatar
44 votes

What is the difference between tabular, tabular* and tabularx environments?

Check out the following MWE: \documentclass{article} \usepackage{tabularx} \begin{document} \begin{tabular}{|l|c|r|} \hline foo & bar & fubar \\ fubar & toobar & foo \\ ...
Philipp Imhof's user avatar
39 votes

Reducing column separation between specific columns

The column specification allows for the insertion of @{<stuff>} between columns. If <stuff> is empty (as in @{}), no column gap is inserted, while the "default" is @{\hspace{\tabcolsep}} ...
Werner's user avatar
  • 588k
38 votes

How can I draw this complex table in LaTeX?

I'd like to propose you choose a layout that's quite different from the screenshot shown in your query. While that layout features a certain hierarchy of objects, the multitude of line styles give it ...
Mico's user avatar
  • 478k
37 votes
Accepted

“Paragraph ended before \verbatim@ was complete.” when trying to use verbatim in tabular

Use \begin{frame}[fragile]. This option is needed when the content contains verbatim.
Ulrike Fischer's user avatar
37 votes
Accepted

labels with tabular

You can't \label a tabular, because a tabular does not receive an intrinsic ordering scheme (aka a number) that can be referenced. But if you place the tabular inside of a table, you can \label that. ...
Steven B. Segletes's user avatar
34 votes

Text alignment on top with multirow command

This is easily handled with the newly updated multirow command. There is an option that specifies vertical text alignment; put [t] for top alignment. In your example you would write: \multirow[t]{3}{...
Learn_and_Share's user avatar
34 votes
Accepted

Setting table-width exactly to linewidth

I think you have two good choices and a (likely) dreadful choice: Use a tabular* environment, Use a tabularx environment (or its close cousin, tabulary) Use the basic tabular environment and scale ...
Mico's user avatar
  • 478k
33 votes

newline in multirow environment

Simple with makecell, which is done for this sort of things: use the \multirowcell command (syntax even simpler than \multirow): \documentclass{article} \usepackage[frenchb]{babel} \usepackage[T1]{...
Bernard's user avatar
  • 269k
33 votes

What is the difference between tabular, tabular* and tabularx environments?

I will begin by showing a screenshot of tabular, tabular* and tabularx versions of one and the same, admittedly contrived, table. The material in the first column is left-aligned; the material in the ...
Mico's user avatar
  • 478k
32 votes
Accepted

Repeating the same column type

No pgffor package is required for this; just write your table preamble as: \begin{tabular}{l *{6}{n{2}{3}}} The general syntax is: *{n}{column(s) pattern} where n is the number of repetitions, ...
Bernard's user avatar
  • 269k
31 votes
Accepted

Changing width of table lines

Update Use \arrayrulewidth from the preamble and place it before the desired table using a group to keep the change to \arrayrulewidth local: \documentclass[11pt]{article} \usepackage{array} \begin{...
Gonzalo Medina's user avatar
30 votes
Accepted

Convert this table to latex

As shown, this is a relatively complex table to format well since it requires the following elements: rotated cells -> rotating package cells which span multiple columns -> \multicolumn{<number of ...
cfr's user avatar
  • 186k
29 votes

How to add a forced line break inside a table cell

Here I use stacks to accomplish it. Several things are noteworthy: I demonstrate \Longstack , \Longunderstack and \Centerstack, which give three different alignments. In order not to squeeze against ...
Steven B. Segletes's user avatar
29 votes

Add notes under the table

You can use {\raggedright insert notes here \par} after \end{tabular} but before \end{table}: \documentclass{article} \begin{document} \begin{table} \centering \caption{Sample ANOVA table} ...
pietro's user avatar
  • 685
29 votes

Beautiful table samples

Unfortunately, as of 2018-11-12, the tabu package is still unmaintained (see repository) and color are not working anymore. Therefore my example below is not working. Here is my modest contribution. ...
29 votes

Drawing Karnaugh's maps in LaTeX

Some days ago (Nov. 26), Mat­tias Ja­cob­s­son uploaded his karnaugh-map package to CTAN. Now instead of the code in my alternative answer you can use a real package. karnaugh-map is also based in ...
Ignasi's user avatar
  • 134k
29 votes

How to create a table with fixed column widths

This workaround in the preamble solves the problem. You can simply use C{width} for centered entries. Replace C with L or R if raggedright or raggedleft is favoured. \usepackage{array} \newcommand{\...
Emre Kantar's user avatar
29 votes
Accepted

Autofit a table to the column width

EDIT @Mico pointed out a much better solution to this problem, as tabularx already comes with the column type X, which automatically does what you want: \documentclass{article} \usepackage{tabularx}...
samcarter_is_at_topanswers.xyz's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible