当前位置:文档之家› latex表格制作详解

latex表格制作详解

latex表格制作详解
latex表格制作详解

L A T E X Table Hints and Tips

Adrian P.Robson

adrian.robson@https://www.doczj.com/doc/ed2681398.html,

1st June,2013

Contents

1Introduction2 2Standard Tables2 3Spacing2

3.1Row Spacing (2)

3.1.1Arraystretch (2)

3.1.2Extrarowheight (3)

3.1.3Bigstruts (3)

3.1.4Comparison of Methods (4)

3.2Column Spacing (4)

4Decimal Point Alignment5 5Vertical Alignment and Text Wrapping6 6Ragged Right Alignment6

6.1Simple Command (6)

6.2Column Types (7)

6.3Tabulary (7)

6.4Comparison of Methods (7)

7Multiple Rows8

7.1Multiple Rows with Text Wrapping (9)

7.2Over Sized Spanning Rows (10)

8Table Headings11

8.1Heading Alignment (11)

8.2Sideways Headings (11)

9Specifying Table Width12

9.1Tabularx (12)

9.2Tabulary (13)

9.3Comparison of Methods (13)

10Larger Tables13

10.1Sideways (13)

10.2Longtable (14)

11Footnotes in Tables15 12Professional Layout15

1

1Introduction

This is a collection of various methods for laying out and formatting L A T E X tables.All of these examples work with pdfL A T E X[13],which is the author’s preferred tool.

A more general discussion of L A T E X methods can be found in L A T E X Hints and Tips[12].

2Standard Tables

Tables are made in L A T E X using the tabular environment like this \begin{tabular}{|l|l|l|}

\hline

\multicolumn{3}{|c|}{A Table}\\\hline \hline

1,1&1,2&1,3\\\hline

2,1&2,2&2,3\\\cline{1-2}

3,1&3,2&\\\hline

\end{tabular}

A Table 1,11,21,3 2,12,22,3 3,13,2

For more information on basic tables consult a good text like The Not So Short Introduction to L A T E X2ε[10].

3Spacing

3.1Row Spacing

The standard row height is too small when\hline is used.There are three ex-plicit ways of correcting this:modifying the arraystretch command,changing the extrarowheight length,or using the bigstrut command.Alternatively, the booktabs or ctable packages can be used as discuses in§12.

3.1.1Arraystretch

The crudest way to increase row spacing,which works without any additional packages,is to increase the arraystretch ratio.This injects space above and below all of the rows’text.It is done like this:

{

\renewcommand{\arraystretch}{1.2}

\begin{tabular}{|c|l|}

\hline

a&Row1\\\hline

b&Row2\\\hline

c&Row2\\

d&Row4\\\hline

\end{tabular}

}

The renewcommand and the table are enclosed in braces to limit the scope of the rede?nition.Its e?ect is to turn

2

a Row1

b Row2

c Row3

d Row4into

a Row1

b Row2

c Row3

d Row4

and with a

bigger value

a Row1

b Row2

c Row3

d Row4

3.1.2Extrarowheight

A more sophisticated approach is to used the array package[8]and change the length\extrarowheight as follows:

\usepackage{array}

...

{

\setlength{\extrarowheight}{1.5pt}

\begin{tabular}{|l|l|}

\hline

a&Row1\\\hline

b&Row2\\\hline

c&Row3\\

d&Row4\\\hline

\end{tabular}

}

This adds space only above the text.With the correct value,it compensates for the\hline command spacing.Its e?ect is to turn

a Row1

b Row2

c Row3

d Row4into

a Row1

b Row2

c Row3

d Row4

and with a

bigger value

a Row1

b Row2

c Row3

d Row4

3.1.3Bigstruts

The above methods apply the compensation to all rows,even if they do not have\hline commands.A subtler alternative is to use the bigstrut package [11]like this:

\usepackage{bigstrut}

...

\begin{tabular}{|l|l|}

\hline

a&Row1\bigstrut\\\hline

b&Row2\bigstrut\\\hline

c&Row2\bigstrut[t]\\

d&Row4\bigstrut[b]\\\hline

\end{tabular}

3

which changes the basic table

a Row1

b Row2

c Row3

d Row4into

a Row1

b Row2

c Row2

d Row4

The\bigstrut command is used when there is are\hline above and below; \bigstrut[t]when there is an\hline only above;and\bigstrut[b]when there is only one below.

The bigstrut package only works well with tables that have single line cells. It does not work with the text wrap column speci?ers p{},m{}and b{}.(For more information on text wrap see§5).

3.1.4Comparison of Methods

The a?ect of the three methods is as follows:

arraystretch{1.2}extrarowheight{1.5pt}bigstrut

a Row1

b Row2

c Row3

d Row4a Row1

b Row2

c Row3

d Row4

a Row1

b Row2

c Row2

d Row4

For tables without text wrapping,the bigskip approach is de?nitely the best if the table has some rows without horizontal lines.Otherwise,extrarowheight is less verbose and gives a more compact https://www.doczj.com/doc/ed2681398.html,e arraystretch if the table needs a large row height.For tables with text wrapping,extrarowheight is probably best.

3.2Column Spacing

Column width can be modi?ed by changing\tabcolsep like this:

\setlength{\tabcolsep}{10pt}

\begin{tabular}{|l|l|}

\hline

a&Row1\\\hline

b&Row2\\\hline

c&Row3\\\hline

\end{tabular}

which changes the default

a Row1

b Row2

c Row3into

a Row1

b Row2

c Row3

There is a standard column speci?er@{cmnd},which suppresses inter-column space and inserts cmnd instead.This can be used to insert or remove space into a particular column.For example:

4

\setlength{\extrarowheight}{1.5pt}

\begin{tabular}{|@{\hspace{1cm}}l|@{}l|}

\hline

Abcd&Abcd\\\hline Abcd&Abcd\\

\hline

\end{tabular}Abcd Abcd Abcd Abcd

4Decimal Point Alignment

The traditional method of aligning decimal points uses the@command.Two columns are used for a decimal number,and a multicolumn command is used in the heading,as the following shows:

\begin{tabular}{|l|r@{.}l|l|}

a&\multicolumn{2}{c|}{b}&c\\ test&2&8&test\\

test&1&45&test\\

test&0&5&test

\end{tabular}a b c test 2.8test test 1.45test test0.5test

A disadvantage of this method is that the numbers are expressed in the code without a decimal point.

As an alternative,the dcolumn package[1]allows decimal numbers to be expressed naturally in a single column.The package de?nes a column speci?er D{}{}{}

The?rst argument is the decimal separator character used in the code,the second is the character in the output,and the last is the number of decimal places.Typically,a newcolumntype command is used in the preamble to make table declaration a little simpler.

Even though there is just one column,A multicolumn command still has to be used to get the correct alignment and font style in the header,as the following example shows:

\newcolumntype{d}[1]{D{.}{.}{#1}}

...

\begin{tabular}{|l|d{2}|l|}

a&\multicolumn{1}{c|}{b}&c\\ test&2.8&test\\

test&1.45&test\\

test&0.5&test

\end{tabular}a b c test2.8test test1.45test test0.5test

As the example shows,using an appropriate positive value for number of decimal places produces the same table layout as the traditional method.This aligns the decimal places,and minimises the column width.

Alternatively,a negative value for decimal places will centre the decimal place in the column,but will not minimise the width.For number lists with reasonably balanced whole and decimal parts this looks good.However,for lists

5

with disproportionate whole and decimal parts,the columns can have too much empty space,as the following shows:

a b c test208.6test test1.45test test0.532test a b c test2000008.6test test1.45test test0.5test

5Vertical Alignment and Text Wrapping

Vertical alignment can be controlled with the array package[8],which has additional text wrap formatting commands:

p{width}Top align,the same as usual.

m{width}Middle align

b{width}Bottom align

These produce the following layouts:

Column Format

p{}p{}l

11 11 1122

22

33

Column Format

m{}m{}l

11

11

11

22

22

33

Column Format

b{}b{}l

11

11

11

22

2233

Notice how the m{}or b{}alignment a?ects the whole table.In addition,p{} m{}and b{}formats cannot be successfully mixed in the same table.

Occasionally the text wrap formats cause‘bad box’warnings,which can often be resolved by with\raggedright(see§6).

6Ragged Right Alignment

For narrow wrapped text blocks left justi?cation often looks best,and can get rid of’bad box’warnings.There are three ways to achieve this:a simple command, column types,and the tabulary package.All of these methods support or can be adapted to provide alignments other than left justi?ed.The?rst two are very versatile and can be used to inject general formatting commands.

6.1Simple Command

The most verbose but?exible way to achieve left justi?cation is just to use \raggedright in the cell:

\newcommand{\rr}{\raggedright}

\newcommand{\tn}{\tabularnewline} ...

{\renewcommand{\arraystretch}{1.2} \begin{tabular}{|c|p{5cm}|}

\hline

1,1&\rr...text...\tn\hline 2,1&...text...\\\hline \end{tabular}}1,1Lorem ipsum

dolor sit amet,

consectetur

adipiscing elit. 2,1Nullam rhon-cus,sem luctus

ultrices.

6

Using this method for left justi?cation can be applied to individual cells. Note that\tabularnewline replaces\\in the row containing the\raggedright command.The de?nitions for\rr and\tn are just to make things a little more compact.

6.2Column Types

Another way of managing ragged right formatting is to de?ne a new column type using the array package[8].Its>{decl}option inserts decl directly before the entry for the column;and<{decl}directly after.The following shows how it can be used:

\usepackage{array}

...

\newcolumntype{x}[1]

{>{\raggedright}p{#1}} \newcommand{\tn}{\tabularnewline} ...

{\renewcommand{\arraystretch}{1.2} \begin{tabular}{|c|x{5cm}|}

\hline

1,1&...text...\tn\hline

2,1&...text...\tn\hline

\end{tabular}}1,1Lorem ipsum

dolor sit amet,

consectetur

adipiscing elit. 2,1Nullam rhoncus,

sem luctus

ultrices.

With this method ragged right formatting is applied to a whole column.The newcolumntype command is used to de?ne a column type that can be reused. However,the formatting could have been embedded in the tabular heading. Again\tabularnewline is needed when\raggedright is used.

6.3Tabulary

Another alternative is to use the tabulary package[4].With this method ragged right columns are simply declared with the L command.However,the total table width must be de?ned as a parameter,as shown below.See§9.2for more on this package.

\usepackage{tabulary}

...

\renewcommand{\arraystretch}{1.2} \begin{tabulary}{6.5cm}{|c|L|}

\hline

1,1&...text...\\\hline

2,1&...text...\\\hline

\end{tabulary}1,1Lorem ipsum dolor sit amet,

consectetur

adipiscing elit.

2,1Nullam rhoncus,

sem luctus ultrices.

6.4Comparison of Methods

Simple commands are useful for small tables or when the formatting does not apply to the whole column.The tabulary package is much simpler than column types,but requires the table width to be speci?ed.Column types can be used for any appropriate formatting or space requirements.

7

7Multiple Rows

The easiest way to have tables with spanning rows is to use the multirow package[11].In its simplest form,it can be used like this:

\usepackage{multirow}

...

\begin{tabular}{|c|l|}

\hline

a&Row1\\\hline

b&\multirow{2}{*}{Spanning rows}\\\cline{1-1}

c&\\\hline

d&Row4\\\hline

\end{tabular}

giving the following:

a Row1

b

Spanning rows

c

d Row4

The\multirow command declares the location of the spanning rows.Its ?rst argument is the number of rows to span.The second,in this case,states that the text argument’s natural width should be used.The relevant columns in lower rows must be left blank.The full multirow command is more complicated: \multirow{nrows}[bigstruts]{width}[fixup]{text}

If the bigstrut package is used,the number of struts in the spanned rows should be stated as the bigstruts parameter.Count2for every\bigstrut and1for a\bigstrut[t]or\bigstrut[b].

The text width can be set with the width parameter,in which case the text will be wrapped and left justi?ed.Line breaks can be forced with a\\ command.However,the text must have no more lines than the number of rows https://www.doczj.com/doc/ed2681398.html,ing an*for the width,as in the example above,makes the column’s cells single line and as wide as necessary.

If the vertical position of the text needs?ne tuning,it can be moved up or down with the fixup optional parameter.

To span rows and columns together,a\multirow should be nested in a \multicolumn.Matching but empty\multicolmn commands are needed for all of the lower spanned rows.

All of these options are shown in the following example:

\begin{tabular}{|c|c|l|l|}

\hline

1,1&1,2&1,3&1,4\bigstrut\\\hline

2,1&

\multirow{2}[4]{1.5cm}{Four bigstruts}&

\multirow{3}[6]{*}{Six bigstruts}&

\multirow{3}[6]{*}[1ex]{Six bigstruts and fixup}

\bigstrut\\\cline{1-1}

3,1&&&\bigstrut\\\cline{1-2}

4,1&4,2&&\bigstrut\\\hline

5,1&

8

\multirow{2}[2]{*}{Two bigstruts}

&5,3

&5,4\bigstrut[t]\\

6,1&&6,3&6,4\bigstrut[b]\\\hline

7,1&

\multicolumn{2}{l|}{\multirow{2}[4]{*}{Four bigstruts}}

&7,4\bigstrut\\\cline{1-1}\cline{4-4} 8,1&

\multicolumn{2}{l|}{}

&8,4\bigstrut\\\hline

9,1&9,2&9,3&9,4\bigstrut\\\hline

\end{tabular}

1,11,21,31,4

2,1Four

bigstruts Six bigstruts Six bigstruts and?xup 3,1

4,14,2

5,1

Two bigstruts 5,35,4

6,16,36,4

7,1

Four bigstruts 7,4

8,18,4

9,19,29,39,4

7.1Multiple Rows with Text Wrapping

Multiple row and text wrap column speci?ers(see§5)do not mix well because multirow is left justi?ed,and the the p{},m{}and b{}formats are normally justi?ed.This is shown in the following example,which generates two‘bad box’warnings:

\setlength{\extrarowheight}{1.5pt} \begin{tabular}{|c|p{2cm}|}

\hline

1,1&**text**\\\hline

2,1&\multirow{2}{2cm}{**text**}

\\\cline{1-1} 3,1&\\\cline{1-1} 4,1&\\\cline{1-1} 5,1&\\\hline

6,1&**text**\\\hline

\end{tabular}1,1Lorem ipsum

dolor sit

amet.

2,1Lorem

ipsum dolor

sit amet

consectetur. 3,1

4,1

5,1

6,1Lorem ipsum

dolor sit

amet.

The easiest way to resolve this is to make everything?ush left by de?ning a ragged right column type as described in§6:

\newcolumntype{P}[1]{>{\raggedright}p{#1}}

\newcolumntype{M}[1]{>{\raggedright}m{#1}}

\setlength{\extrarowheight}{1.5pt}

\begin{tabular}{|c|P{2cm}|}%could be|c|M{2cm}|

9

\hline

1,1&\muchlessText \tn\hline

2,1&\multirow{2}{2cm}[-1.5pt]{\lessText }

\tn\cline{1-1}

3,1&\tn\cline{1-1}4,1&\tn\cline{1-1}5,1&\tn\hline 6,1&\muchlessText \tn\hline \end{tabular}

which creates the following layouts:

With P{}With M{}

1,1

Lorem

ipsum dolor sit amet.2,1Lorem

ipsum dolor sit amet consectetur.3,14,15,16,1

Lorem

ipsum dolor sit amet.

1,1Lorem

ipsum dolor

sit amet.2,1

Lorem

ipsum dolor sit amet consectetur.

3,14,15,16,1Lorem

ipsum dolor

sit amet.

7.2Over Sized Spanning Rows

Having a \multirow that has more lines than the rows it spans is not so easy to layout well.Expanding the spanned rows with struts appears to be the only solution,but it requires a lot of trial-and-error adjustments.The following table shows the method:

\newlength{\rowA}

\setlength{\rowA}{8ex}%modify as needed \newcommand{\strutA}{%no space before strut

\rule[-0.45\rowA]{0pt}{\rowA}%put text approx mid strut }...

\begin{tabular}{|c|l|c|}\hline

1,1&1,2&1,3\bigstrut \\\hline

2,1&\multirow{2}{5cm}[1ex]{...lots of text ...}

&2,3\strutA

\\\cline{1-1}\cline{3-3}

3,1&&3,3\strutA \\\hline 4,1&4,2&4,3\bigstrut \\\hline \end{tabular}

10

1,11,21,3

2,1Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Curabitur id nisl nunc,non

adipiscing arcu.Morbi nec leo

sit amet.2,3

3,13,3

4,14,24,3

A\rule of zero width is used for the strut.A negative raise height positions the text in the rows vertical centre.In the example,the strut is put in a centre aligned column.In this context it must be put next to the column’s text with no spaces,or the alignment will be disturbed.This is not normally an issue for other alignments.

For convenience the strut is de?ned as a command called\strutA,which is used in the spanned rows2and3.The height of the strut is given by the length rowA.This is more complicated to write,but makes the trial-and-error layout process easier.Adjust rowA until there is room for the spanning row’s text.The fixup parameter in the\multirow command is used to correct the vertical position of its text as necessary.

8Table Headings

8.1Heading Alignment

It is sometimes nice to have a column heading with a di?erent alignment to its column.The standard multicolumn command can be used to do this:

\begin{tabular}{|l|l|l|}

\hline

\multicolumn{1}{|c}{C1}&

\multicolumn{1}{|c}{C2}&

\multicolumn{1}{|c|}{C2}\\\hline aa&b&cccc\\\hline

aaa&bb&cccc\\\hline

aaaa&bbb&cccc\\\hline

aaaaa&bbbb&cccc\\\hline

aaaaaa&bbbb&cccc\\\hline

\end{tabular}

C1C2C2 aa b c aaa bb cc aaaa bbb ccc aaaaa bbbb cccc aaaaaa bbbb cccc

8.2Sideways Headings

Horizontal space can be saved by printing long column headings sideways.The rotating package[6]can be used to achieve this with its sideways environment:

11

\usepackage{rotating} ...

\begin{tabular}{|l|l|l|} \hline

\multicolumn{1}{|c|}{ \begin{sideways}

Column1\,

\end{sideways}}&

\multicolumn{1}{c|}{

\begin{sideways}

Column22\,

\end{sideways}}&

\multicolumn{1}{c|}{

\begin{sideways}

Column333\,

\end{sideways}}\\\hline aa&bbbb&cccc\\\hline

aaa&bbbb&cccc\\\hline

aaaa&bbbb&cccc\\\hline

aaaaa&bbbb&cccc\\\hline

aaaaaa&bbbb&cccc\\\hline

\end{tabular}

C

o

l

u

m

n

1

C

o

l

u

m

n

2

2

C

o

l

u

m

n

3

3

3

aa bbbb cccc aaa bbbb cccc aaaa bbbb cccc aaaaa bbbb cccc aaaaaa bbbb cccc

The multicolumn method given in§8.1is used to centre the headings;and\, is used to add a little space at the top of the heading.

9Specifying Table Width

The tabularx[3]and tabulary[4]packages are much better than the standard tabular*for specifying table width.

9.1Tabularx

The tabularx environment expands speci?c columns to meet the table’s width requirement.The width of the table is given as a parameter,and the columns that can be expanded are denoted with the X alignment command,as the fol-lowing shows:

\begin{center}

\setlength{\extrarowheight}{1.5pt}

\begin{tabularx}{0.75\textwidth}{|l|X|}

\hline

1,1&**some text**\\\hline

2,1&**some text**\\\hline

\end{tabularx}

\end{center}

1,1Lorem ipsum dolor sit amet,consectetur adipiscing

elit.Curabitur id nisl nunc,non adipiscing arcu.

Morbi nec leo sit amet.

2,1Nullam rhoncus,sem luctus ultrices accumsan,

urna enim fermentum.

12

There must be at least one X column.If there is more than one X column the necessary space is equally distributed.The columns are always padded to give the the table its speci?ed width.Text is wrapped and justi?ed if it does not?t into the column.

Note the use of0.75\textwidth to specify the width as a proportion of page width.

9.2Tabulary

The tabulary environment expands speci?c columns to meet the table’s width requirement and allows alignment to be speci?ed for these columns as follows: L\raggedright

C\centering

R\raggedleft

J normal justi?cation

The maximum width for the table is given as a parameter.However,unlike tabularx,columns are not padded if they are too narrow.

\setlength{\extrarowheight}{1.5pt}

\begin{tabulary}{4cm}{|l|L|}

\hline

1,1&**some text**\\\hline

2,1&**some text**\\\hline

\end{tabulary}

full width...not full width...

1,1Lorem ipsum dolor sit amet,consectetur

adipiscing elit.

2,1Curabitur id nisl nunc, non adipiscing arcu.1,1Lorem ipsum. 2,1Curabitur id.

9.3Comparison of Methods

The tabularx package is useful for absolute table widths,but it has limited alignment options.

The tabulary package provides better alignment options;and its adaptive width behaviour does not normally cause problems.It is convenient to set its width at a suitable maximum,say0.75\textwidth,and let the package select appropriate column widths.

10Larger Tables

Larger tables can sometimes be handled by turning them sideways,or by letting them span pages.

10.1Sideways

The most versatile way to turn a table sideways is to use the sidways environ-ment from the rotate package[6].For example:

13

\usepackage{rotating} ...

\begin{sideways}

\begin{tabular}{|l|l|}

\hline

1,1&1,2\\\hline 2,1&2,2\\\hline \end{tabular}

\end{sideways}1

,

1

1

,

2

2

,

1

2

,

2

This method can be used in a?oating table environment or just embedded in the text.

10.2Longtable

The longtable package is designed to make tables that span page breaks.It is rather complicated to use,and its documentation[2]should be consulted for all of its features.It maintains column widths across page breaks,and centres the table.There are reports of incompatibility with many other packages,but for simple use it appears to be okay.Multiple compilation passes are normally needed to get the layout correct.Here is a very simple example:

\usepackage{longtable}

\usepackage{array}%for extrarowheight

\setlength{\extrarowheight}{1.5pt}

\begin{longtable}{|l|l|}

%header------------------------

\hline

Heading1&Heading2\\\hline\hline

\endhead

%header------------------------

Lorem ipsum...&Consectetur...\\\hline

Lorem ipsum...&Consectetur...\\\hline

.

.

\end{longtable}

Heading1Heading2

Lorem ipsum dolor sit amet.Consectetur adipiscing elit.

Lorem ipsum dolor sit amet.Consectetur adipiscing elit.

Lorem ipsum dolor sit amet.Consectetur adipiscing elit.

--------Page break--------

Heading1Heading2

Lorem ipsum dolor sit amet.Consectetur adipiscing elit.

Lorem ipsum dolor sit amet.Consectetur adipiscing elit.

14

In the example above,\extrarowheight is used to improve the table’s ver-tical spacing.Alternatively arraystretch could be use if space is needed below the lines.However,the normally useful bigstrut package does not work with longtable.See§3.1for more about these methods.

11Footnotes in Tables

A footnote in a non-?oating longtable or tabulary table is put with any normal page footnotes at the end of the page containing the table.When a longtable breaks over a page,footnotes are placed on the correct page.Table and page footnotes have the same counter,and are numbered from the start of the document.Floating tables cannot have normal footnotes.

Footnotes can be kept next to their table by using a minipage to hold the table.Each minipage has its own disjoint footnote counter,and uses alphabetic lower case footnote marks.This method does not work for tabulary,but it can be used with?oating tables.The following is a tabular example:

\begin{minipage}{6cm}

\begin{tabular}{|l|l|}

\hline

1,2&1,2\footnote{This is a footnote.}

\\\hline

2,1&2,2\\\hline

3,1&3,2\\\hline

\end{tabular}

\end{minipage}1,21,2a

2,12,2

3,13,2

a This is a footnote.

12Professional Layout

The booktabs package[7]provides support for‘formal tables,’which the pack-age’s author promotes as a better way of presenting data.In particular,he derides the use of vertical rules and double rules.Here is an example taken from the package documentation:

\begin{tabular}{llr}

\toprule

\multicolumn{2}{c}{Item}\\

\cmidrule(r){1-2}

Animal&Description&Price(\$)\\ \midrule

Gnat&per gram&13.65\\

&each&0.01\\

Gnu&stuffed&92.50\\

Emu&stuffed&33.33\\ Armadillo&frozen&8.99\\

\bottomrule

\end{tabular}

Item

Animal Description Price($)

Gnat per gram13.65

each0.01 Gnu stu?ed92.50 Emu stu?ed33.33 Armadillo frozen8.99

As this shows,the package provides better vertical spacing around horizontal rules.

There is also the derived ctable package[5],which focuses on table and ?gure?oats,and provides facilities for making table https://www.doczj.com/doc/ed2681398.html,po Mori’s article Tables in L A T E X2ε:Packages and Methods[9]has a detailed discussion of good table layout and the ctable and booktab packages.

15

References

[1]David Carlisle,The dcolumn package.Download from https://www.doczj.com/doc/ed2681398.html,/

tex-archive/macros/latex/required/tools/dcolumn.pdf

[2]David Carlisle,The longtable package.Download from https://www.doczj.com/doc/ed2681398.html,/

tex-archive/macros/latex/required/tools/longtable.pdf

[3]David Carlisle,The tabularx package.Download from https://www.doczj.com/doc/ed2681398.html,/

tex-archive/macros/latex/required/tools/tabularx.pdf

[4]David Carlisle,The tabulary package.Download from https://www.doczj.com/doc/ed2681398.html,/

tex-archive/macros/latex/contrib/tabulary/tabulary.pdf

[5]Wybo Dekker,The ctable package.Downloadable from https://www.doczj.com/doc/ed2681398.html,/

tex-archive/macros/latex/contrib/ctable/ctable.pdf

[6]Robin Fairbairns,Sebastian Rahtz and Leonor Barroca,A package for

rotated objects in L A T E X.Downloadable from https://www.doczj.com/doc/ed2681398.html,/tex-archive/

macros/latex/contrib/rotating/rotating.pdf

[7]Simon Fear,Publication quality tables in L A T E X.Download from www.ctan.

org/tex-archive/macros/latex/contrib/booktabs/booktabs.pdf

[8]Frank Mittelbach and David Carlisle,A new implementation of L A T E X’s

tabular and array environment.Downloadable from https://www.doczj.com/doc/ed2681398.html,/

tex-archive/macros/latex/required/tools/array.pdf

[9]Lapo Filippo Mori,Tables in L A T E X2ε:Packages and Methods,The

PracT E X Journal,2007,No.1.Downloadable from https://www.doczj.com/doc/ed2681398.html,/pracjourn/

2007-1/mori/mori.pdf

[10]Tobias Oetiker,The Not So Short Introduction to L A T E X2ε.Downloadable

from https://www.doczj.com/doc/ed2681398.html,/tex-archive/info/lshort/english/lshort.pdf

[11]Piet van Oostrum,?ystein Bache and Jerry Leichter,The multirow,

bigstrut and bigdelim packages.Downloadable from https://www.doczj.com/doc/ed2681398.html,/

tex-archive/macros/latex/contrib/multirow/doc/multirow.pdf

[12]Adrian Robson,L A T E X Hints and Tips.Download from https://www.doczj.com/doc/ed2681398.html,/

docs/latexTricks.pdf

[13]The TeX Users Group(TUG),The pdfT E X project page.Available at

https://www.doczj.com/doc/ed2681398.html,/applications/pdftex

16

[Version3.1,tableTricks.tex,11/03/15,13:49]

latex,两个表格并排

竭诚为您提供优质文档/双击可除latex,两个表格并排 篇一:latex表格排版——多行多列合并 latex多列表格合并单元格排版 效果如下图所示: 复制下面代码直接可以运行 \begin{table}[!h] \centering \caption{parametersofsRoi}\label{tab2} \begin{tabular}{cccccccc} \hline \multicolumn{1}{c}{\multirow{2}{1.2cm}{number}} &\multicolumn{5}{c}{(Frequency,scale)} &\multicolumn{1}{c}{\multirow{2}{1.6cm}{directionnu mber}} &\multicolumn{1}{c}{\multirow{2}{1.6cm}{directionin crement}}

\\ \cline{2-6} \multicolumn{1}{c}{} &\multicolumn{1}{c}{1}&{2}&{3}&{4}&{5} &\multicolumn{1}{c}{} \\ \hline Filterbank1&(0.50,61)&(0.50,67)&(0.55,61)&(0.55,66) &(0.60,51)&8&$\pi/8$\\ Filterbank2&(0.20,63)&(0.35,71)&(0.35,89)&(0.37,105 )&(0.40,103)&8&$\pi/8$\\ Filterbank3&(0.20,79)&(0.25,94)&(0.30,75)&(0.30,107 )&(0.35,54)&8&$\pi/8$\\ \hline \end{tabular} \end{table} 篇二:latex并列图和子图的代码 1.两个并列的图 \begin{figure}[h]

LaTeX入门教程

LaTeX入门教程 里面的图好多都刷不出来,于是我就自己运行了一遍,至少验证了这个教程的正确性O(∩_∩)O哈哈~ CTEX - 在线文档- TeX/LaTeX 常用宏包 资料下载: LaTeX2e插图指南LaT eX2e使用手册TeX语言CTeX FAQ 常见问题集 Contents ?TEX/L A TEX是什么? ?为什么要用TEX/L A TEX? ?安装 ?开始使用 ?数学符号 o行内公式与行间公式 o上标与下标 o常见的数学公式 o行列式与矩阵 o方程组与分段函数 ?使用中文 ?文章的各个部分 ?表格 ?插图 ?罗列 ?分割长文档 ?学习资料 ?幻灯片制作简介 ?重要建议 ?Bibliography T E X/L A T E X是什么? T E X 是一个非常优秀的排版软件,L A T E X 是基于T E X 之上的一个宏包集。因为L A T E X 的出现,使得人们使用T E X 更加容易,目前大部分人们使用的T E X 系统都是L A T E X 这个宏集。 为什么要用T E X/L A T E X? 我们为什么要用T E X/L A T E X 来排版我们的论文、书籍呢?因为它 ?排版的效果非常整齐漂亮; ?排版的效率高; ?非常稳定,从95年到现在,T E X 系统只发现了一个bug。由此可见它的稳定性; ?排版科技文献,尤其是含有很多数学公式的文献特别方便、高效。现今没有一个排版软件在排版数学公式上面能和T E X/L A T E X 相媲美; 安装 我们可以从https://www.doczj.com/doc/ed2681398.html,上下载最新的中文T E X 套装,Windows 用户请下载CT E X 套装,Linux 用户可以下载TeXlive 来安装。安装过程就不用我多说了吧!

LaTeX表格制作

目录 第一章表格环境的定义4第二章表格环境参数格式4§2.1位置可选参数 (4) §2.2列必选参数 (5) 第三章表格文本行中的命令5§3.1\tabularnewline命令 (5) §3.2\hline命令 (5) §3.3\cline{n-m}命令 (6) §3.4\vline命令 (6) §3.5\multicolumn{数}{列}{文本}命令 (6) §3.6@表达式:@文本 (6) 第四章表格样式参数命令7§4.1\tabcolsep命令 (7) §4.2\arrayrulewidth命令 (7) §4.3\doublerulesep命令 (7) §4.4\arraystretch命令 (7) 第五章表格示例8§5.1无线表格 (8) §5.2带竖线的表格 (8) §5.3带水平及竖线的表格 (8) §5.4复杂的表格 (10)

表格 1无线表格 (8) 2带竖线的表格 (9) 3带水平及竖线的表格 (9) 4利用@表达式生成表格 (9) 5一张复杂的表格 (10)

第一章表格环境的定义 环境tabular和tabular*是生成表格的基本工具1,其定义(语法)如下: \begin{tabular}[位置]{列} 行 \end{tabular} \begin{tabular*}{宽度}[位置]{列} 行 \end{tabular*} tabular环境可以用来排版带有横线和竖线的表格,L A T E X自动确定表格的宽度;tabular*环境与tabular环境类似,只是可以用参数指定表格的整体宽度,另外列参数必须在第一 列后面的某个地方包含一个合适的表达式(见下面说明)。通常,为了使表格在页面上居中,要利用center环境: \begin{center}表格\end{center} 第二章表格环境参数格式 §2.1位置可选参数 该参数表示表格相对于外部文本行基线的位置,又称为垂直定位参数,有三种情况:?t:表格顶部与当前外部文本行的基线重合 ?b:表格底部与当前外部文本行的基线重合 ?缺省(不使用):表格按照外部文本行的基线垂直居中 1在数学模式下使用的array环境的语法和参数的意义与tabular环境中的完全一样

(完整word版)LaTeX入门教程v2.doc

计算机与 IT 入门实验讲义 LaTeX入门实验实验手册 大连理工大学软件学院 实训基地 2016 年 7 月

1 LaTeX 简介 LaTeX( L A T E X ,音译“拉泰赫”)是一种基于ΤΕΧ的排版系统,由美国计 算机学家莱斯利·兰伯特( Leslie Lamport)在 20 世纪 80 年代初期开发,利用这种格式,即使使用者没有排版和程序设计的知识也可以充分发挥由 TeX 所提供的强大功能,能在几天,甚至几小时内生成很多具有书籍质量的印刷品。对于生成复杂表格和数学公式,这一点表现得尤为突出。因此它非常适用于生成高印刷质量的科技和数学类文档。这个系统同样适用于生成从简单的信件到完整书籍的所有其他种类的文档。 LaTeX 编辑器有很多,这里我们使用 WinEdt,它是 CTeX 自带的一款,功能比较齐全,也是我的入门编辑器。入门首推这款,下载CTeX 即可,也可以单独安装。 2 WinEdt 指南 首先我们来简单了解WinEdt 的使用,打开 WinEdt,新建空白文件,软件的基本界面如图所示。工具栏中蓝色框内为编译模式选项,本次实验中我们选择选择 PDFLaTeX。编译后我们可以使用该下拉菜单下的PDFTeXify 选项查看生成的PDF。

3 LaTeX 案例讲解 本次实验我们以 example.pdf 文档的编写为例讲解LaTex 编写文档的过程, 涉及到中文支持,图片插入,公式编辑,表格编辑,算法编辑等。文档对应的 .tex 源文件为 example.tex。 3.1 LaTeX 宏定义及中文支持 LaTex 宏定义主要设置了文档的基本格式和以及源文档编译时会用到的包。 如案例文档的源文件中,设置了如下的宏定义: \documentclass指定了要编写的文档类型为普通的文章。3-4 行设定了文档中 的段落要首行缩进两个空格,最后两行设定了文档的页边距,即上下左右均留出1.0cm 的空白。 LaTeX 在默认情况下不能支持中文字符,因此为了支持文档中的中文,我们 需要导入相应的中文包,其中最常用的方法是导入CJK 包,具体的命令如上图 第二行所示, \usepackage{CJK}。 3.2 LaTeX 文档结构 LaTeX 的文档包括宏定义和正文两个大部分,其中正文部分要写在一组 \begin{} 和\end{} 标签,如下所示 \end{document} 后面的内容不会出现在生成的文档中。 由于本案例中需要使用中文,要额外添加一对标签 \begin{CJK*} \end{CJK*},

Latex排版——复杂表格制作

Latex排版——复杂表格制作 %多行或多列合并的情况 %(1)多行合并代码如下 \documentclass{article} \usepackage{multirow} %使用multirow必须加载该package \begin{document} \begin{table}[tbp] \centering \begin{tabular}{|ccccc|ccccc|} \hline Case & Structural \ State & Damage \ Location & Damage \ extent & Excitation \ Level(V) \\ \hline % \hline 在该行下面画一整条横线 32 & \multirow{6}{*}{Damaged States (DS3)} & 1C and 3A & DB0 & 2 \\ % * 表示由系统自动调整文字 33 & & 1C and 3A & DB0 & 5 \\ 34 & & 1C and 3A & DB0 & 8 \\ 35 & & 1C and 3A & DBB & 2 \\ 36 & & 1C and 3A & DBB & 5 \\ 37 & & 1C and 3A & DBB & 8 \\ \hline \end{tabular} \caption{List of unknown states} \end{table} % (2)多行多列同时合并 \begin{table} \begin{tabular}{|c|c|c|c|c|} \hline \hline \multirow{2}{*}{multi-rows} & \multicolumn{2}{|c|}{multi-columns} & \multicolumn{2}{|c|}{\multirow{2}{*}{multi-row and col}} \\ \cline{2-3} % \cline用于画横线 \cline{i-j}表示从第i列画到第j列 & column-1 & column-2 & \multicolumn{2}{|c|}{} \\ \hline label-1 & label-2 & label-3 & label-4 & label-5 \\

LaTeX入门教程v2

计算机与IT入门实验讲义LaTeX入门实验实验手册 大连理工大学软件学院 实训基地 2016年7月

t h e b e n g a r e g o o d f o 1LaTeX 简介 LaTeX (L A T E X ,音译“拉泰赫”)是一种基于ΤΕΧ的排版系统,由美国计算 机学家莱斯利·兰伯特(Leslie Lamport )在20世纪80年代初期开发,利用这种格式,即使使用者没有排版和程序设计的知识也可以充分发挥由TeX 所提供的 强大功能,能在几天,甚至几小时内生成很多具有书籍质量的印刷品。对于生 成复杂表格和数学公式,这一点表现得尤为突出。因此它非常适用于生成高印刷质量的科技和数学类文档。这个系统同样适用于生成从简单的信件到完整书 籍的所有其他种类的文档。 LaTeX 编辑器有很多,这里我们使用WinEdt ,它是CTeX 自带的一款,功能比较齐全,也是我的入门编辑器。入门首推这款,下载CTeX 即可,也可以单独安装。 2WinEdt 指南 首先我们来简单了解WinEdt 的使用,打开WinEdt ,新建空白文件,软件 的基本界面如图所示。工具栏中蓝色框内为编译模式选项,本次实验中我们选择选择PDFLaTeX 。编译后我们可以使用该下拉菜单下的PDFTeXify 选项查看生成的PDF 。

3LaTeX案例讲解 本次实验我们以example.pdf文档的编写为例讲解LaTex编写文档的过程, 涉及到中文支持,图片插入,公式编辑,表格编辑,算法编辑等。文档对应的. tex源文件为example.tex。 3.1 LaTeX宏定义及中文支持 LaTex宏定义主要设置了文档的基本格式和以及源文档编译时会用到的包。如案例文档的源文件中,设置了如下的宏定义: \documentclass指定了要编写的文档类型为普通的文章。3-4行设定了文档 中的段落要首行缩进两个空格,最后两行设定了文档的页边距,即上下左右均 留出1.0cm的空白。 LaTeX在默认情况下不能支持中文字符,因此为了支持文档中的中文,我 们需要导入相应的中文包,其中最常用的方法是导入CJK包,具体的命令如上 图第二行所示,\usepackage{CJK}。 3.2 LaTeX文档结构 LaTeX的文档包括宏定义和正文两个大部分,其中正文部分要写在一组 \begin{}和\end{} 标签,如下所示 由于本案例中需要使用中文,要额外添加一对标签\begin{CJK*} \end{CJK*},

LaTeX画表格

竭诚为您提供优质文档/双击可除 LaTeX画表格 篇一:latex排版——表格插入 latex排版——表格插入 标签:分类:办公与排版 latex tabel 杂谈 %看以下代码: \documentclass{article} \begin{document} structuralhealthmonitoring(shm)isafast-developing,i nterdisciplinaryfieldofresearchduetothefactthatshmi sheavilystimulatedbytheengineeringproblemsofmainten anceandsafeoperationoftechnicalinfrastructure. $$\sum_{i=1}^{n}$$ thecoreproblemofshmisthedamageidentification,whichc

anbedividedintofivelevels %表格 \begin{table}[tbp] \centering%表居中 \begin{tabular}{lccc}%{lccc}表示各列元素对齐方式,left-l,right-r,center-c\hline player2)localizationofdamage;3)identificationofdama getype;4)quantificationofdamageextent;and5)damagepr ognosis. \end{document} %编译后如下格式 %将红色代码tbp改为htbp,编译后显示为 篇二:latex制作复杂表格之multirow,multicolum和cline综合使用简介 latex制作复杂表格之multirow,multicolum和cline 综合使用简介已有2283次阅读20xx-5-1817:04|个人分类:table|系统分类:科研笔记|关键 词:latex,table,multirow,multicolum,cline 在复杂表格制作中,有时候会遇到一列横跨多行,或者一行横跨多列的情况,那么这个时候就要分别用到 \multirow,\multicolum的命令,标准语法如下:

LATEX中表格的制作

LATEX中表格的制作 一,基本表格制作 标准 LaTeX 提供有 array 和 tabular 两个制表环境,它们的完整格式如下:\begin{array}[表格位置]{列样式} \end{array} \begin{tabular}[表格位置]{列样式} \end{tabular} \begin{tabular*}{表格总宽度}[表格位置]{列样式} \end{tabular*} 这两个环境的选项和参数定义是相同的,不过 array 主要用于数组矩阵的排版,且只能用在数学环境中,如 equation 等。 array 宏包扩展了 array 和 tabular 环境功能,主要增加和增强了列样式选项,甚至可编程定义新的列样式;还增加了许多细部微调功能,如改变垂直表格线的粗细和自动调整表格间隙等。使用该宏包可以排印出外形美观、功能丰富的表格。 该宏包没有任何选项,扩展后的两个环境的列样式选项: 选项说明 l 该列左对齐排列 c该列居中排列 r该列右对齐排列 p{列宽}设置该列宽度,文本顶对齐 @{声明}该列每行插入声明中文本 m{列宽}设置该列宽度,文本居中对齐 b{列宽}设置该列宽度,文本底对齐 >{声明}声明可以是命令或插入列元素之前的文本 <{声明}声明可以是命令或插入列元素之后的文本 |列边或列间加入一条垂直线 !{声明}用声明要求的样式取代列间垂直线

应用举例: 列样式还可设置为:>{\setlength{\parindent}{26pt }}p{ 列宽},对该列文本行或段落缩排。 Frank Mittelbach et al 它定义了三条划线命令:\toprule、\midrule 和 \bottomrule,可分别对表格顶部、中部和底部使用不同粗细的水平线,见下例:

LaTeX新人教程,教你快速入门

LaTeX新人教程,30分钟从完全陌生到基本入门 by Nan 对于真心渴望迅速上手LaTeX的人,前言部分可以跳过不看。 本教程面向对LaTeX完全无认知无基础的新人。 旨在让新人能够用最简单快捷的方式,轻松入门,能够迅速使用LaTeX完成基本的文本编辑。 尤其旨在破除部分新人对LaTeX在传闻中难以学习的恐惧感。 在入门之后,面对各种进阶应用、特殊要求与异常状况,可以自行咨询google 解决。 先用三句话来介绍什么是LaTeX,以下三点基于我个人的主观经验的总结。 https://www.doczj.com/doc/ed2681398.html,TeX是一类用于编辑和排版的软件,用于生成PDF文档。 https://www.doczj.com/doc/ed2681398.html,TeX编辑和排版的核心思想在于,通过\section和\paragraph等语句,规定了每一句话在文章中所从属的层次,从而极大方便了对各个层次批量处理。 https://www.doczj.com/doc/ed2681398.html,TeX在使用体验方面,最不易被Word替代的有四个方面:方便美观的数学公式编辑、不会乱动的退格对齐、非所见即所得因此可以在编辑的时候用退格和换行整理思路但生成PDF出来不影响美观、部分导师和刊物不接受Word排版的文章。 我要严厉警告和强烈声讨那些自以为是advanced LaTeX user的人。请你们不要为了自己那一点可怜可悲的虚荣心,去刻意渲染LaTeX有多么高端多么不容易学习,这和孔乙己炫耀茴香豆的茴字有四种写法有什么区别么?混账!LaTeX到底有多“难”你们自己清楚好么?同理的还有很大一部分的VI user,还有Linux user,还有Fallout player。卧槽,一个软件而已,有什么好显摆的。别人想学LaTeX,好,你随手给人家丢一个几百页的英文Manual,显得自己很高端吗?你自己看过了吗?你推荐给别人的时候真的有希望别人看完吗?只是装逼的话就是混账! 我写这一篇教程的动机,正是因为网络上能够找到的简要速成的LaTeX教程完全没有。我能找得到的最简短或是说在我看来最具有指导意义的,就是那篇《一份不太简短的LaTeX介绍》。然而对于希望迅速对LaTeX有所了解的人,那一篇“不太简短的介绍”也仍旧稍嫌略长,我当初在入门时也研究了整晚。在LaTeX社区群里聊得久了,大家都是朋友,既然缺了这一块我又有闲情,那么就补上了。因此我写了这一篇教程,完全是以教会新人上手为目的,把华而不实的内容统统略去,确保能够在三十分钟内跟着这个教程走完全步骤就可以基本算是“玩转

latex各种命令使用帮助

+---------------------------------+ |TeX各版本概述及基本约定,特殊字符| +---------------------------------+ tex提供300多条基本排版命令 由D.E.Knuth1978年开发 plain tex:在tex基础上新定义600多条复合命令 AMS-TEX:美国数学会开发(amsmath宏包)排版的数学公式 LATEX:https://www.doczj.com/doc/ed2681398.html,mport(1985)编写,适合排版普通文章和书籍 LATEX2e:可加载amsmath宏包,目前最流行的TEX宏包 版本:LATEX2.09-->LATEX2e-->LATEX3(开发中) 中文排版: CCT:科学院张林波 TY(天元):华师大肖刚、陈志杰教授开发 CJK:德国W.Lemberg开发,处理中日韩三国文字。 发行版CTEX:集成了CCT,TY,CJK的MikTEX系统。 ChinaTEX:内容涵盖MiKTeX系统及中文支持、常用外围软件、TeX\LaTeX文档和模板选萃等 TeX中的长度 mm毫米 cm厘米 in英寸=2.54cm=72.27pt pt点 em大写字母M的宽度 ex小写字母x的高度 弹性长度:根据需要自动伸缩 正常值plus伸展值minus收缩值 实际长度可超过正常值和伸展值之和,但不能小于正常值和收缩值之差 \documentclass[11pt]{article}%11pt字体,普通文章 %导言区,全局命令 \usepackage{CJK}%使用CJK宏包 \begin{document}%主环境 \begin{CJK}{GBK}{song}%汉字必须放入CJK环境 %其它字体:song,kai,fs,hei,li,you %CJK的两种环境CJK和CJK* %GBK是采用的字符集:GB,GBK,Bg5,Gbt Hi,This is my first \LaTeX file 祝贺你,MikTex和CJK安装成功了 \end{CJK} \ent{document}

latex使用教程升级版

%EXTERNAL FILES: %Name of language file: \cfile=. %Name of included files: \jfile=physjour,.mbs. head,\MBopta} \from{physjour.mbs}{\MBopta} \from{merlin.mbs}{tail,\MBopta}} \def\MBopta{% %<>INTERNAL LANGUAGE SUPPORT (if no external language file) %<