TeXnik - Tips TeX and LaTeX

Welcome to the TeXnik website (under construction)

TUG logo

Main page

Search CTAN:


Google c.t.t.

Google d.c.t.t.



@ symbol | 
A arraycolsep | 
B Boxed Line or Column in an Array | 
C caption (Problems) |  Caption in Longtable |  Cases without math |  Centered columns with a fixed width |  colortbl package (colored cells) |  Column separation | 
D Dashed lines in tables |  dcolumn -- Decimal columns |  Dynamical Tables | 
E Examples |  Excel tabels | 
F Figure and Text and vertical alignment |  Floatflt |  Float placement |  fontsize tablewide |  footnotes in tables |  Fractions in Tables | 
H Header/Footer and tables |  Height of the Rows |  Horizontal space in tables | 
I Importing Excel tabels | 
L Lineheight in arrays/tables |  Longtable |  LTX tabulars | 
M Mathsf in a table |  Multirow | 
N  | 
O Overlays | 
P parbox with table |  Placement of Floats | 
R Raggedright lines |  Rotating Tabulars |  Rowheight in arrays/tables |  Row style | 
S Shaded Parts |  Sideways Tabulars | 
T tabcolsep |  Table and figure side by side |  Tables side by side |  Tables - vertical space |  tabular* Example |  tabularx |  Text and Figure and vertical alignment |  Textline - behind table |  Text flows around Table | 
U  | 
V Variable Number of Rows |  Vertical Lines (width) |  Vertical space in arrays/tables |  Vertical spacing for Figure and Text |  Vertically multicols | 
W Width of a table |  Width of Vertical Lines | 
Z Zeilenhöhe in arrays/tables  | 
Available Packages on CTAN


Between two colums of a tabular/array LaTeX inserts two times the space \tabcolsep / \arraycolsep. One time before and one time after the optional vertical line. This additional space can be overwritten with the @{} operator. Its argument can hold any command and can be empty, which is the same than a zero width.


To get a tabular with a specific width, e.g. the textwidth, you can use package tabularx. For an example go here. There exists also a longtable version of tabularx, the package ltablex. In the preamble write
For the columns which widths should be set by the package choose the column type X.

In case of a very small last column choose
Remember that in those columns \\ ends the column line not the tabular line, which is possible with \tabularnewline.
Dynamical TablesExample
Creating Tables with a command like
is possible with the following stuff in the preamble:
  \toks@=\expandafter{\the\toks@ #1}}

 \count@=0 %
  \advance\count@ by 1 %
   \the\count@. Row \tabularnewline}%
It produces the output:
1. Row
2. Row
3. Row
4. Row
5. Row

Fractions in Tables
Fractions look extremely ugly in tables, because there is no space over under. Write the following code in the preamble and then use $\tabfrac{...}{...}$ when writing math fractions in tables.
This writes a fbox without a rule but with the fboxsep. For another example look here.

Raggedright Rows
When having p{..} columns which are left-, rightaligned or centered, then a \\ at the end of the row ends the textline but not the tabularline. In this case still use \tabularnewline. F.ex.:

Vertical space between rows
Write before your table/array f.ex.:
You can choose any other factor for the spacing.

For eqnarray (also all amsmath special environments) use


Column separation
\tabcolsep is the half space between two cells in tables. There are two ways to change this value:
The values are only examples. With the first one you are able to reset the value behind a table with the positive value or viceversa.
Possible are all valid units, like pt, cm,...
The commands may be in LaTeX preamble or anywhere in the text.
This command is not possible in the array environment!

it's also possible to turn off the separation when you insert as an argument @{}c|c@{} (as an example for a 2*2 table with no borders on the left and the right)

On the other hand you can insert any character as a separation, e.g. a "=". The following code defines this character as column separator and defines a macro specialLine which has no separator:

parbox as table
To define a parbox we need a width. With the tabular environment we can define a "dynamic" parbox:

  • insert a 1x1 tabular with \begin{tabular}{@{}c@{}}.
  • Now you can write anything into the table and the "parbox" gets the width of the longest line.

    Importing Excel Tables
    try package excel2latex, available at CTAN.

    Header/Footer and tables
    It is possible to put tables in the header or footer. For example a table in the header. In Latex preamble

    In Latex Preamble or in the text:
    a & b \\\hline
    c & d\\\hline
    gives the following table in the header

    tablewide fontsize
    for changing the font for the whole table write just before the table (outside)
    or any other fontsize. Just behind the table (outside)
    Or alternative when you want all tables with the font size \tiny

    Footnotes in tables
  • in the table write in tex (red) \footnotemark
  • outside of the table or the floating table (all in texmode - red)
    \footnotetext{... the footnotetext ...}
    \stepcounter{footnote}\footnotetext{... the next footnotetext ...}
    n is the number of footnotes in your table, e.g. 3, than you have to write \addtocounter{footnote}{-2}.This command is not necessary if there is only one footnote.

    Table - Vertical Space
    Same height for all rows
    this works for tables and arrays too!
    In latex preamble or anywhere else:
    \renewcommand\arraystretch{MyValue}% (MyValue=1.0 is for standard spacing)
    Different height for single rows
    Write in latex preamble:
    \newlength{\myVSpace}% the height of the box
    \setlength{\myVSpace}{1ex}% the default, 
    \newcommand\xstrut{\raisebox{-.5\myVSpace}% symmetric behaviour, 
    and than once in every table- or arrayline  
    \xstrut defines an unvisible box with the specific height. You can change the height with

    Automatic Lineheight
    With package tabls.

    Mathsf in tables
    It needs some tricky code to get a table column in sf mode:


    local time: Tue Apr 16 08:35:36 CEST 2024 ; file is: 1758.92791666667 days old
    contact webmaster _at_ TeXnik.de