Monthly Archives: October 2010

LaTex footnote.

일언절언 wrote..
: 안녕하세요,
: 이력서를 레이텍으로 작성하고 있는데 학술 발표 논문을 쭉 적으면서 발표
: 자에게 daggar형태의 각주를 달고 문서의 아래에 "daggar로 표시된 자가
: 발표자"라는 하나의 커멘트만 달고 싶습니다.
: footnote 명령은 계속 번호가 증가하고 매 항목마다 아래 설명이 붙기 때
: 문에 사용이 불가능할 것 같구요 어떻게 이런 문제를 처리할 수 있을까요?
: 감사합니다.

맨 첫번째 각주는 내용을 붙이고 그 뒤로는 \footnotemark만 써서 각주를
공유하게 하면 되지 않을까 합니다. 이 트릭이 아마 LaTeX4Wp엔가 나와 있
었던 것으로 기억합니다만...

제가 지금 사용할 수 있는 시스템이 XeLaTeX밖에 없어서 latex 컴파일이
되는 소스를 준비하지 못했는데, 아마 참고는 하실 수 있을 거라 생각합니다.
(daggar는 dagger를 말씀하시는 거라고 보았습니다.)




\setmainfont{Palatino Linotype}
\setkormainfont[맑은 고딕 Bold]{맑은 고딕}




안녕하세요,\footnote{테스트 푸트노트}

이력서를\footnote[2]{발표자} 레이텍으로 작성하고 있는데
학술 발표 논문을\footnotemark[2]
쭉 적으면서 발표자에게 daggar 형태의\footnotemark[2]
각주를 달고 문서의 아래에 “daggar로 표시된 자가\footnotemark[2]
발표자”라는 하나의 커멘트만 달고 싶습니다.

footnote 명령은 계속 번호가 증가하고\footnote{증가합니다.}
매 항목마다 아래 설명이 붙기 때문에 사용이 불가능할 것 같구요
어떻게 이런 문제를 처리할 수 있을까요?



LaTex line spacing.

Line Spacing

If you want to use larger inter-line spacing in a document, you can change its value by putting the


command into the preamble of your document. Use \linespread{1.3} for “one and a half” line spacing, and \linespread{1.6} for “double” line spacing. Normally the lines are not spread, so the default line spread factor is 1.

The setspace package allows more fine-grained control over line spacing. To set “one and a half” line spacing document-wide, but not where it is usually unnecessary (e.g. footnotes, captions):


To change line spacing within the document, the setspace package provides the environments singlespace, onehalfspace, doublespace and spacing:

This paragraph has \\ default \\ line spacing.
  This paragraph has \\ double \\ line spacing.
  This paragraph has \\ huge gaps \\ between lines.

LaTeX/Page Layout

Latex and the document class will normally take care of page layout issues for you. For submission to an academic publication, this entire topic will be out of your hands, as the publishers want to control the presentation. However, for your own documents, there are some obvious settings that you may wish to change: margins, page orientation and columns, to name but three. The purpose of this tutorial is to show you how to configure your pages.



[edit] Page Dimensions

A page in Latex is defined by myriad internal parameters. Each parameter corresponds to the length of an element of the page, for example, \paperheight is the physical height of the page. Here you can see a diagram showing all the variables defining the page:

Latex layout.svg

  1. one inch + \hoffset
  2. one inch + \voffset
  3. \oddsidemargin = 31pt
  4. \topmargin = 20pt
  5. \headheight = 12pt
  6. \headsep = 25pt
  7. \textheight = 592pt
  8. \textwidth = 390pt
  1. \marginparsep = 10pt
  2. \marginparwidth = 35pt
  3. \footskip = 30pt
  • \marginparpush = 7pt (not shown)
  • \hoffset = 0pt
  • \voffset = 0pt
  • \paperwidth = 597pt
  • \paperheight = 845pt

It will not have been immediately obvious – because it doesn’t really cause any serious problems – that the default page size for all standard document classes is US letter. This is shorter by 18 mm (about 3/4 inch), and slightly wider by 8 mm (about 1/4 inch), compared to A4 (which is the standard in almost all the rest of the world). As I said, it’s not a great problem, and most printers will print the page without a hiccup. However, it is possible to specify alternative sizes.


The above example illustrates how to pass the optional argument to the \documentclass, which will then modify the page dimensions accordingly. The standard document classes that are a part of Latex are built to be fairly generic, which is why you have the flexibility of specifying the page size. Other classes may have different options (or none at all). Normally, 3rd party classes come with some documentation to let you know.

Readers from a word processing background are probably thinking why there is so much white space surrounding the text. There is a good reason, and it’s all down to readability. Have a look in a few books, and pick a few lines at random. Count the number of characters per line. I bet the average is about 66. Studies have shown that it’s easier to read text when there are 60-70 characters per line – and it would seem that 66 is the optimal number. Therefore, the page margins are set to ensure that readability remains as good as possible. Also, white space is often left in the inner margin for the assumption that the document will be bound.

If you wish to change the margins of your document, there are many ways to do so:

  • Simply use the fullpage package for somewhat standardized smaller margins (around an inch):

For an even greater effect give it the cm option (around 1.5cm):

  • Use the a4wide package for a page with A4 document size with smaller margins.
  • Use the geometry package. This package allows you to specify the 4 margins without needing to remember the particular page dimensions commands. It may be implemented as follows:
\usepackage[top=tlength, bottom=blength, left=llength, right=rlength]{geometry}
  • Edit individual page dimension variables described above, using the \addtolength and \setlength commands. For instance,

Additionally, there are several packages designed to solve the problem of varying pages sizes, which override any defaults setup by the document class. One of the most versatile packages for page layout is the geometry package. For instance, to set the page size, add the following to your preamble:


The geometry package has many pre-defined page sizes, like a4paper, built in. Others include: a0paper, a1paper, …, a6paper, b0paper, b1paper, …, b6paper, letterpaper, legalpaper, executivepaper.

To explicitly change the paper dimensions using the geometry package, the paperwidth and paperheight options can be used. For example:

\usepackage[margin=1in, paperwidth=5.5in, paperheight=8.5in]{geometry}

[edit] Page size issues

If you intend to get a pdf in the end, there are basically three ways:

TeX => PDF
TeX => DVI => PDF
TeX => DVI => PS => PDF

Which are in general obtained with

pdflatex myfile
latex myfile
dvipdf myfile
dvips myfile -o
ps2pdf myfile.pdf

With all the available Ghostscript versions, the safest way to always get the right paper size in the end is to add


to the tex file, -t a4 after dvips and -sPAPERSIZE=a4 after the ps2pdf. For pdflatex to work fine, using the package geometry usually works.

If you want US Letter instead, replace “210mm,297mm” by “8.5in,11in” and “a4″ by “letter”.

[edit] Page Orientation

When you talk about changing page orientation, it usually means changing to landscape mode, since portrait is the default. I shall introduce two slightly different styles of changing orientation.

The first is for when you want all of your document to be in landscape from the very beginning. There are various packages available to achieve this, but the one I prefer is the geometry package. All you need to do is call the package, with landscape as an option:


Although, if you intend to use geometry to set your paper size, don’t add the \usepackage commands twice, simply string all the options together, separating with a comma:


The second method is for when you are writing a document in portrait, but you have some contents, like a large diagram or table that would be displayed better on a landscape page. However, you still want the consistency of your headers and footers appearing the same place as the other pages.

The lscape package is for this very purpose. It supplies a landscape environment, and anything inside is basically rotated. No actual page dimensions are changed. This approach is more applicable to books or reports than to typical academic publications. Using pdflscape instead of lscape when generating a PDF document will make the page appear right side up when viewed: the single page that is in landscape format will be rotated, while the rest will be left in portrait orientation.

Also, to get a table to appear correctly on a landscaped page, one must place the tabular environment inside a table environment, which is itself inside the landscape environment. e.g., it should look like this:

\centering     % optional, probably makes it look better to have it centered on the page

[edit] Page Styles

Page styles in Latex terms refers not to page dimensions, but to the running headers and footers of a document. These headers typically contain document titles, chapter or section numbers/names, and page numbers.

[edit] Standard page styles

The possibilities of changing the headers in plain Latex are actually quite limited. There are two commands available: \pagestyle{style} will apply the specified style to the current and all subsequent pages, and \thispagestyle{style} will only affect the current page. The possible styles are:

empty Both header and footer are clear
plain Header is clear, but the footer contains the page number in the center.
headings Footer is blank, header displays information according to document class (e.g., section name) and page number top right.
myheadings Page number is top right, and it is possible to control the rest of the header.

With myheadings, the commands \markright (in the standard document classes, book, report and article) and \markboth (only in the book class) are used to control the headings. The following commands placed at the beginning of an article document will set the header of all pages to contain “John Smith” top left, “On page styles” centered and the page number top right:

\markright{John Smith\hfill On page styles\hfill}

An issue to look out for is that the major sectioning commands (\part, \chapter or \maketitle) specify a \thispagestyle{plain}. So, if you wish to suppress all styles by inserting a \pagestyle{empty} at the beginning of your document, then the style command at each section will override your initial rule, for those pages only. To achieve the intended result one can follow the new section commands with \thispagestyle{empty}. The \part command, however, cannot be fixed this way, because it sets the page style, but also advances to the next page, so that \thispagestyle{} cannot be applied to that page. Another approach is to simply write \usepackage{nopageno} in the preamble. This package will make \pagestyle{plain} have the same effect as \pagestyle{empty}, effectively suppressing page numbering when it it used.

[edit] Customising with fancyhdr

To get better control over the headers, one can use the package fancyhdr written by Piet van Oostrum. It provides several commands that allow you to customize the header and footer lines of your document. For a more complete guide, the author of the package produced this documentation.

The tricky problem when customizing headers and footers is to get things like running section and chapter names in there. LaTeX accomplishes this with a two-stage approach. In the header and footer definition, you use the commands \rightmark and \leftmark to represent the current section and chapter heading, respectively. The values of these two commands are overwritten whenever a chapter or section command is processed. For ultimate flexibility, the \chapter command and its friends do not redefine \rightmark and \leftmark themselves. They call yet another command (\chaptermark, \sectionmark, or \subsectionmark) that is responsible for redefining \rightmark and \leftmark.

If you want to change the look of the chapter name in the header line, you need only “renew” the \chaptermark command.

To begin, add the following lines to your preamble:


The second line will prevent LaTeX from giving a warning. Both the header and footer comprise three elements each according to its horizontal position (left, centre or right). To set their values, the following commands are available:

\lhead[lh-even]{lh-odd} \lfoot[lf-even]{lf-odd}
\chead[ch-even]{ch-odd} \cfoot[cf-even]{cf-odd}
\rhead[rh-even]{rh-odd} \rfoot[rf-even]{rf-odd}

Hopefully, the behaviour of the above commands is fairly intuitive: if it has head in it, it affects the head etc, and obviously, l, c and r means left, centre and right respectively. Documents can be either one- or two-sided. Articles are by default one-sided, books are two-sided. Two-sided documents differentiate the left (even) and right (odd) pages, whereas one-sided do not.

Watch out: if you give long text in two different “parts” only in the footer or only in the header, you might see overlapping text, be careful. There are special commands you can use as arguments:

\thepage number of the current page
\leftmark current chapter name printed like “CHAPTER 3. THIS IS THE CHAPTER TITLE”
\rightmark current section name printed like “1.6. THIS IS THE SECTION TITLE”
\thesection current section number

Note that \leftmark and \rightmark convert the names to uppercase, whichever was the formatting of the text. If you want them to print the actual name of the chapter without converting it to uppercase use the following command:


now \leftmark and \rightmark will just print the name of the chapter and section, without number and without affecting the formatting. Moreover, with the following commands you can define the thickness of the decorative lines on both the header and the footer:


The first line for the header, the second for the footer. Setting it to zero means that there will be no line.

An example:

\lhead{Andrew Roberts}

It is often necessary to clear any defaults or a previous style definition, and the first line of the above example will do this. The commands are an alternative interface to customising the headers/footers that fancyhdr offers, and so by not passing anything to them, it assumes that you want it all blank.

The result of these commands will put my name at the top left, todays date at the top right, and the current page number at the bottom right of the page. Even if the document class was two-sided, because no optional text has been supplied for the even pages, the style will be used for all pages.

This approach has a serious bad point: some pages like the title or the beginning of each chapter have no header or footer, but with the code we have shown every page will get the same output. There is a way to solve this problem: you can use the fancyplain style. If you do so, you can use the command \fancyplain{...}{...} inside \lhead{...} etc.

When LaTeX wants to create a page with an empty style, it will insert the first argument of fancyplain, in all the other cases it will use the second argument. So, an improved version of the previous code would be:

\lhead{\fancyplain{}{Andrew Roberts}}

It has the same behavior of the previous code, but you will get empty header and footer in the title and at the beginning of chapters.

For two-sided, it’s common to mirror the style of opposite pages, you tend to think in terms of inner and outer. So, the same example as above for two-sided is:

\lhead[Andrew Roberts]{}
\rhead[]{Andrew Roberts}

This is effectively saying my name is top outer, todays date is top inner, and current page number is bottom outer. You can use the fancyplain command within them for two-sided documents, too.

As an example, here is the complete code of a basic configuration you could use for a real document:


NB. If you want to make the article class two-sided, use \documentclass[twoside]{article}.

[edit] Another approach with fancyhdr

If you want to get different style for even and odd pages, there is another possible way, still using fancyhdr. Start again with:


it will just delete the current heading/footer configuration, so you can make your own. Now you can create what you want using the command \fancyhead for header and \fancyfoot for footer. They work in the same way, so we’ll explain only the first one. The syntax is:

\fancyhead[selectors]{output you want}

The selectors are the following:

E even page
O odd page
L left side
C centered
R right side

so CE will refer to the center of the even pages and RO to the right side of the odd pages. Whether it is header or footer, depends if you are using \fancyhead or \fancyfoot. You can use multiple selectors separated by a comma. Here is an example:

\fancyhead[CE]{Author's Name}

it will print author’s name on the center of the header of the even pages, the date of the current day on the center of the odd pages and the current page number on the left size of even pages and on the right size of the odd pages. Finally, in order to have the pages at the beginning of any chapter really plain, you could redefine the plain style, for example to have a really plain page when you want. The command to use is \fancypagestyle{plain}{...} and the argument can contain all the commands explained before. An example is the following:

\fancypagestyle{plain}{ %
\fancyhf{} % remove everything
\renewcommand{\headrulewidth}{0pt} % remove lines as well

Finally, here is the complete code of a possible style you could use for a two-sided document:

\fancypagestyle{plain}{ %
\fancyhf{} % remove everything
\renewcommand{\headrulewidth}{0pt} % remove lines as well

[edit] Page n of m

Some people like to put the current page number in context with the whole document. LaTeX only provides access to the current page number. However, you can use the lastpage package to find the total number of pages, like this:

\cfoot{\thepage\ of \pageref{LastPage}}

Note the capital letters. Also, add a backslash after \thepage to ensure adequate space between the page number and ‘of’. And recall, when using references, that you have to run LaTeX an extra time to resolve the cross-references.

[edit] Multi-column Pages

It is common to see articles and conference proceedings formatted with two columns of text. However, such publishers will usually provide you with their own document class, which automatically implements this format, without you having to do anything. It is very easy to format your page in this way. If you are using a standard Latex document class, then you can simply pass the optional argument twocolumn to the document class: \documentclass[twocolumn]{article} which will give the desired effect.

While this simple addition will do the job 9 out of 10 times, it is widely acknowledged that there are many limitations of this approach, and that the multicol package is much more useful for handling multiple columns. It has several advantages:

  • Can support up to ten columns.
  • Implements a multicols environment, therefore, it is possible to mix the number of columns within a document.
  • Additionally, the environment can be nested inside other environments, such as figure.
  • Multicol outputs balanced columns, whereby the columns on the final page will be of roughly equal length.
  • Vertical rules between columns can be customised.
  • Column environments can be easily customised locally or globally.

Floats are not fully supported by this environment. It can only cope if you use the starred forms of the float commands (e.g., \begin{figure*} ) which makes the float span all columns. This is not hugely problematic, since floats of the same width as a column may be too small, and you would probably want to span them anyway.

To create a typical two-column layout:

  lots of text

The parameter \columnseprule holds the width of the vertical rules. By default, the lines are omitted as this parameter is set to a length of 0pt. Do the following before the beginning of the environment:


This will draw a thin line of 1pt in width. A thick line would not look very pleasing, however, you are free to put in any length of your choosing. Also, to change the horizontal space in between columns (the default is set at 10pt, which is quite narrow) then you need to change the \columnsep parameter:


[edit] Manual Page Formatting

There may be instances, especially in very long documents, such as books, that Latex will not get all page breaks looking as good as it could. It may, therefore, be necessary to manually tweak the page formatting. Of course, you should only do this at the very final stage of producing your document, once all the content is complete. Latex offers the following:

\newline Breaks the line at the point of the command.
\\ Breaks the line at the point of the command, it’s a shorter version of the previous command but it does exactly the same
\\* Breaks the line at the point of the command and additionally prohibits a page break after the forced line break
\linebreak[number] Breaks the line at the point of the command. The number you provide as an argument represents the priority of the command in a range from 0 (it will be easily ignored) to 4 (do it anyway). LaTeX will try to produce the best line breaks possible, meeting its high standards. If it cannot, it will decide whether including the linebreak or not according to the priority you have provided.
\newpage Ends the current page and starts a new one.
\pagebreak[number] Breaks the current page at the point of the command. The optional number argument sets the priority in a scale from 0 to 4.
\nopagebreak[number] Stops the page being broken at the point of the command. The optional number argument sets the priority in a scale from 0 to 4.
\clearpage Ends the current page and causes any floats encountered in the input, but yet to appear, to be printed.

[edit] Widows and orphans

Wikipedia-logo.png Wikipedia has related information at Widows and orphans

In professional books, it’s not desirable to have single lines at the beginning or end of a page. In typesetting such situations are called ‘widows’ and ‘orphans’. Normally it is possible that widows and orphans appear in LaTeX documents. You can try to deal with them using manual page formatting, but there’s also an automatic solution.

LaTeX has a parameter for ‘penalty’ for widows and orphans (‘club lines’ in LaTeX terminology). With the greater penalty LaTeX will try more to avoid widows and orphans. You can try to increase these penalties by putting following commands in your document preamble:


If this does not help, you can try increasing these values even more, to a maximum of 10000. However, it is not recommended to set this value too high, as setting it to 10000 forbids LaTeX from doing this altogether, which might result in strange behavior.

It also helps to have rubber band values for the space between paragraphs:

\setlength{\parskip}{3ex plus 2ex minus 2ex}

[edit] Summary

This tutorial is relatively short, largely due to the fact that the whole LaTeX ethos is to concentrate on the content, and let LaTeX (and/or other typographers who have developed suitable document classes) decide on the best presentation. The next step to achieve greater control of page layout is to set about designing your own class. Unfortunately, that is not a straightforward task, and is often best left to the professionals!

Previous: Formatting Index Next: Mathematics

This page uses material from Andy Roberts’ Getting to grips with Latex with permission from the author.