From Wikibooks, open books for an open world
Jump to navigation Jump to search

If you have a question when dealing with LaTeX and are in need of some help, please refer to How to get help.

Please do not add a new section here.


Getting Started
  1. Introduction
  2. Installation
  3. Installing Extra Packages
  4. Basics
  5. How to get help

Common Elements

  1. Document Structure
  2. Text Formatting
  3. Paragraph Formatting
  4. Colors
  5. Fonts
  6. List Structures
  7. Special Characters
  8. Internationalization
  9. Rotations
  10. Tables
  11. Title creation
  12. Page Layout
  13. Customizing Page Headers and Footers‎
  14. Importing Graphics
  15. Floats, Figures and Captions
  16. Footnotes and Margin Notes
  17. Hyperlinks
  18. Labels and Cross-referencing
  19. Initials


  1. Errors and Warnings
  2. Lengths
  3. Counters
  4. Boxes
  5. Rules and Struts

Technical Text

  1. Mathematics
  2. Advanced Mathematics
  3. Theorems
  4. Chemical Graphics
  5. Algorithms
  6. Source Code Listings
  7. Linguistics

Special Pages

  1. Indexing
  2. Glossary
  3. Bibliography Management
  4. More Bibliographies

Special Documents

  1. Scientific Reports (Bachelor Report, Master Thesis, Dissertation)
  2. Letters
  3. Presentations
  4. Teacher's Corner
  5. Curriculum Vitae
  6. Academic Journals (MLA, APA, etc.)

Creating Graphics

  1. Introducing Procedural Graphics
  2. MetaPost
  3. Picture
  4. PGF/TikZ
  5. PSTricks
  6. Xy-pic
  7. Creating 3D graphics


  1. Macros
  2. Plain TeX
  3. Creating Packages
  4. Creating Package Documentation
  5. Themes


  1. Modular Documents
  2. Collaborative Writing of LaTeX Documents
  3. Export To Other Formats

Help and Recommendations

  1. FAQ
  2. Tips and Tricks


  1. Authors
  2. Links
  3. Package Reference
  4. Sample LaTeX documents
  5. Index
  6. Command Glossary

edit this boxedit the TOC

Who?[edit | edit source]

Who wrote this? It seems a rather phenomenal piece of work! We'd love to publish an article or a notice about it in one of the TeX journals. I looked at the history of a couple pages, but the answer was not apparent ... anyway, thanks, whoever you are!

well, there is the authors section for this :-) I wrote lots of parts of the book. As you can see, we have the permission to include several existing books on LaTeX here. I have added most of the "not so short introduction...", but I still have to finish. As soon as I have a lot of free time (July I guess), I'll work on introducing all of them and this will be a very good book, (hopefully) having the best of all the others. The main good point is that LaTeX changes quite quickly, while most of the existing guides are really old and mostly outdated. This Wikibook gets updated continuously thanks to lots of contributors. I have seen lots of anonymous users fixing some smaller mistakes. Alessio Damato 08:31, 21 May 2007 (UTC)

Cyrillic letters[edit | edit source]

How can I write a text in Cyrillic using "math" command? Is it possible?

>> According to Tobias Oetiker's "The Not So Short Introduction to LaTex2e", you need to add the mathtext package before the fontenc package. Here is what might go at the top of the document:

\DeclareSymbolFont{T2Aletters}{T2A}{cmr}{m}{it} % Italic cyrillic letters

When you are in math mode, remember that to show regular text you use the {\text{}} command. I added extra braces because there are certain cases where you need them.

See also: LaTeX/Internationalization#Cyrillic script

splitting a project into files (\includeonly)[edit | edit source]

I've been using \includeonly{} and \include{} as described under the advanced topics section of the wikibook, but am not sure the output is what it should be: If I put a \label{marker} command in a file foo.1, and then put a \ref{marker} command in a file foo.2, then even though I use \includeonly{foo.1,foo.2} in the rootfile preamble and \include{foo.2} (and no other \include{} command) in the rootfile body, I'm told that the reference was undefined. I thought that \includeonly{} allowed one to preserve cross-references without having to process more than one wants to see. Can anyone tell me what I'm doing wrong? Thanks. -- 18:01, 31 January 2007 (UTC)

Using LaTeX on a website[edit | edit source]

Is it possible to use LaTeX on a personal website in much the same way it is used in Wikipedia, i. e. when LaTeX commands immediately appear as automatically generated picture files?

no you can't. Wikipedia stores the sources (containing LaTeX parts as well) and converts them to HTML and images before sending it to user's browser. You should use a software doing the same (or you can use WikiMedia, too), but you need to set up the server properly... Alessio Damato 16:29, 20 August 2007 (UTC)

Thank you. 19:44, 22 August 2007 (UTC)

yes, it do is possible, using the right CGI-scripts
One easy way to do this is to use MathJax: [1]. You just put
<script type="text/javascript"

in the document head. Then in the body just use $...$, $$...$$ or \(...\), \[...\] to enclose mathematical formulas. Ashaio (discusscontribs) 09:19, 8 June 2011 (UTC)

Multi-line title[edit | edit source]

Hi, I'm quite new to latex and there's something I'd need to do but I'm not able to, nor i could find any hint over the net. What i need is to create a multi-line document main title - it seems easy but i couldn't work it. If someone could help me i would really appreciate it.

[EDIT] OK, I'm ever newer to wikis and i can't create a new topic. Sorry for the mess.

Thank you in advance Antonio

Use \\ at the end of each line. Ashaio (discusscontribs) 09:19, 8 June 2011 (UTC)

Can anyone please tell me what does the command ``punt does?

book-writing[edit | edit source]

~October 4, 2008 how do i write a book using latex? is there an available template?

What do you mean by 'book'? A textbook/manual? A novel? Anyway, you should start by specifying document class book and know how to start chapter. There's more about creating table of contents and index. --Derbeth talk 17:06, 8 October 2008 (UTC)

Is there a powerful way for add chemical structures in my papers using Latex? Now i've to add images created with a graphic design software, but it's a really slow way to write them. Nothing like a text definition of chemical structures in Latex with subsequent graphical output? Thank you.

Ok. Let me google that for you. -- (discuss) 00:19, 29 March 2012 (UTC)

address labels[edit | edit source]

I'm trying to output an address list (home addresses, telephone numbers, email addresses, etc.) in a standard address label-like format. In other words, I'd like, say, 3 labels across, and N labels down (whatever will fit on the page). I've looked at (and used) the labels package, but I don't like one aspect of its formatting. Each of the labels is centered in its "cell". This means that if one label is 3 lines long and another is 6 lines long, the tops of the address labels don't line up horizontally. This is probably considered a "feature", but what I'd like to achieve is that all the "first lines" line up while each address label having possibly different numbers of lines.

Does anyone know how to do this? I'd like output that looks like this:

Address 1/Line 1           Address 2/Line 1            Address 3/Line 1
Address 1/Line 2           Address 2/Line 2            Address 3/Line 2
Address 1/Line 3           Address 2/Line 3            Address 3/Line 3
                           Address 2/Line 4            Address 3/Line 4
                           Address 2/Line 5

Address 4/Line 1           etc.  
Address 4/Line 2
Address 4/Line 3
Address 4/Line 4

Clearly, the size of each "box" should be large enough for the label with the greatest number of lines.

If you have any suggestions, please let me know. If possible, I'd like to have each address label be defined in the same way as in the labels package -- blank lines separate addresses, but other representations would be ok too.

Thanks. (talk) 02:35, 4 November 2008 (UTC) Eric

Section numbering in the PDF version?[edit | edit source]

Dear Contributors! The LaTeX wikibook is a really impressive and valuable piece of work, thanks a lot! Would it be possible to include [[[sub]sub]sub]section numbering in the PDF version? It would enhance its usability even further!

\renewcommand for section doesn't work[edit | edit source]

Hello! I wanted to have every section in a new page. So I thought I could renewcommand section to newpage and then section, like:

\renewcommand{section}{\newpage \section}

However, this freezes my compiler (I am using xelatex). Is it a problem of recursion? Does it not like recursive calls to the same function when renewing it?

Anyway, thinking that could be a problem of recursion, I tried an other way:

\renewcommand{\section}{\newpage \oldsection}

This should avoid recursion, but it freezes my compiler anyway. Any idea? Thanks a lot! -- (talk) 23:58, 8 February 2009 (UTC)

You need to take a snapshot of \section using let:
\renewcommand{\section}{\newpage \oldsection}
-- (talk) 12:45, 1 April 2009 (UTC)

Chemistry in LaTeX?[edit | edit source]

As the question already asked above was ignored, I'll try it again. Is there an acceptable way to write chemical formulas? - (talk) 14:46, 19 March 2009 (UTC)

If you just wish to write formulas, then there is a package mentioned in the formatting section (search for chemical). If you wanted to produce graphical structures, then you could try searching for a package at the CTAN website, see the installing packages section.

If you mean chemical structures, ochem probably is what you are looking for. You can find it here.

chemfig can also be used to draw 2D chemical structures. Unlike ochem, chemfig does not require Perl.

mhchem is fantastic for making entry of formulas and their associated subscripts etc. easier.

More chemistry[edit | edit source]

What about drawing larger molecular structures, such as CNTs, fullerenes, micelles and reverse micelles?

format arguments in newcommand[edit | edit source]

In the following newcommand, (how) can the argument be centered, *on the same line* as the labelenumi in the marginpar?

\newcommand{\answer}[1]{\leavevmode\marginpar{\labelenumi\hspace{5pt} #1}}

(Inserting the centering environment between \hspace{5pt} and the argument #1 creates a line space in the marginpar--at least in pdflatex.)

A modified box may be required, but is there a different solution? Thanks -- (talk) 14:18, 17 May 2009 (UTC)

How can I write latex online & see my letter? May,30.09

Sir, I want to learn latex and writing a book in latex. I have seen the pdf version of this Latex book which is very beautifull and worth reading. Can i get the latex script of the book i.e. .tex file (Latex.pdf-> Latex.tex )? kindly e-mail me on i will be waiting eagerly for your reply. Muhammad Sohaib Ayub Bachelors of Information Technology National University Of Science And Technology Pakistan.

Citations -- DOI[edit | edit source]

How does one include the DOI in citations?

figure and table position within page[edit | edit source]

I have three questions about how to manage the table and figure within a page: 1)although I have used \newpage in front of every \begin{figure}[H] or \begin{table}[H], sometimes LaTex still put 2 items on one page.

2)For those did appear separately on each page, I can not let the figure located close enough to the caption.

3)Below is the code for two figures I put in. They appear separately on two pages as I wanted. Only that the title of the first one appear in the middle of the page so it is not too far away from the graphic. And for the second one, the title appear at the top of the page, which is what I need, but the graphic stays in the middle of the page. Could anyone tell me how to fix the title at the top of page and let the graphic start right after the caption and any text?

Many thanks!

\newpage \begin{figure}[H]\footnotesize \caption{\textbf{Impulse Response Function}} \label{fig:IRF} This figure presents the IRF (Impulse Response Function) of the three auto process estimations.\\

\leavevmode \includegraphics[width=1\textwidth]{IRF.pdf} \end{figure}

%\newpage \begin{figure}[H]\footnotesize \caption{\textbf{AR(2) Estimation of Yearly Drifts}} \label{fig: AR2Est} This figure presents the fitted yearly drifts of rating transitions and the AR(2) estimation of the drifts from the third year onwards of the entire sample period.\\

\includegraphics[width=1\textwidth]{AR2Estimates.pdf} \end{figure}

LaTeX PDF Version with external links[edit | edit source]

I find this book impressive and downloaded the PDF version to be able to use it offline. Unfortunately, all links (e.g. from the glossary) direct me to the web version and not to the local PDF copy. Can this be amended?

Thomas Fischer

This issue seems to be resolved now.--Dirk Hünniger (discusscontribs) 16:14, 23 June 2013 (UTC)

Page format[edit | edit source]

Dear, When i prepare a document, it leaves margins of width more then one inch. But i need only less. How can i reduce the page margins in an article?

Use the geometry package. This package allows you to specify the 4 margins. The values are relative to the edge of paper (0in) and go inward it. It may be implemented as follows:
\usepackage[top=0.8in, bottom=0.8in, left=0.8in, right=0.8in]{geometry}
(See more in LaTeX/Page_Layout). Ashaio (discusscontribs) 09:45, 8 June 2011 (UTC)

How to format many variables? Can I use a wildcard in a new command?[edit | edit source]

There are many vectors in my file and I hope to show them in the form of boldsymbol. So I did as follow:

 \newcommand{\va}{\vect{a}}  % vector a
 \newcommand{\vb}{\vect{b}}  % vector b
 \newcommand{\vc}{\vect{c}}  % vector c
   ....                      %vector d,e,f ...

I don't hope to repeat these similar commands, so I hope to edit them in two options as follow:

1. Create group of these variables which can be shown in particular form, as look like

        \vectgroup{a, b, c, ...} % vector a,b,c,...

2. Using a wildcard in a new command:

        \newcommand{\v*}{\vect{*}} % * can be specialized to a,b,c,...

I believe the Latex have this function, but I cannot implement that. Anyone can give me suggestion? Thousands of thanks.

latex code for cauchy's integral formula

This very book: LaTeX to wiki or wiki to LaTeX?[edit | edit source]

Was this very book created in LaTeX and then converted to a wiki or visa versa?

The PDF version was created with MediaWiki to LaTeX, which, as you may guess, converts the whole wikibook source to LaTeX. --Ambrevar (discusscontribs) 13:31, 23 June 2013 (UTC)

Furthermore the LaTeX source is attached to the PDF version of this book. --Dirk Hünniger (discusscontribs) 16:04, 23 June 2013 (UTC)

Sorting a table alphabetically[edit | edit source]

Hi, Does anybody know how can I sort a table with respect to first column in latex alphabetically? Thanks a lot.

Developing a book in A5[edit | edit source]

Hello everyone,

I wrote my dissertation in A4 with LaTex. Now I wonder what changes should be done so that the dissertation fits into a A5 book for publication?

Two options seem to be feasible:

1. to define the document as a5paper in \documentclass. However, the output file in Pdf viewer is displayed in A4, which makes the format checking difficult.

2. An alternative is using landscape to fit 2 pages of the document into 1 A4 paper. Thus, each A4 page forms 2 successive pages of A5.

Does anyone have a better idea of converting A4 to A5, in preparation for book pulication? Thank you in advance!

Sincerely, Nicole

As above, A5[edit | edit source]

I would love to know how to do this as well. To be precise , entering

\documentclass[10pt,a5paper]{article} \special{papersize=148mm,210mm}


will produce an A5 'page', but what you type in will appear as A4 still, and will be chopped off if it is not within your A5 'page'

Brian Daugherty