Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

How to Start Using LaTeX and BibTeX

938 views

Published on

This tutorial will show you how to get things started with LaTeX and BibTeX. This includes (1) installing LaTeX, (2) creating a first simple document and (3) an overview of the most common functionalities.

Published in: Science

How to Start Using LaTeX and BibTeX

  1. 1. Getting started with LaTeX and BibTeX Installing, compiling and generating a document Paolo Pareti https://w3id.org/people/paolo
  2. 2. 1. Installation 2. First Document 3. Compiling the documents 4. Basic commands 5. Structure of the BibTeX file 6. Summary
  3. 3. 1. Installation The standard LaTeX installation will require to install: 1. TeX distribution 2. LaTeX editor * * Follow the installation instructions of your LaTeX editor, in some cases you will have to configure it to use the TeX distribution you have installed
  4. 4. 1. Installation - Windows 1. A common TeX distributions you can install: ○ http://miktex.org/ 2. LaTex editor ○ http://www.texniccenter.org/ ○ http://tug.org/texworks/ ○ http://www.xm1math.net/texmaker/
  5. 5. 1. Installation - Linux 1. A common TeX distributions you can install: ○ Your specific system’s software source for an available LaTeX installation ○ Alternatively use: http://www.tug.org/texlive/ 2. LaTex editor ○ http://www.xm1math.net/texmaker/ ○ http://tug.org/texworks/
  6. 6. 1. Installation - Mac 1. A common TeX distributions you can install: ○ https://tug.org/mactex/ 2. LaTex editor ○ http://www.xm1math.net/texmaker/ ○ http://tug.org/texworks/
  7. 7. 2. First Document - Main files In a folder, create two documents named: ● paper.tex ● mybib.bib
  8. 8. 2. First Document - Document file Add the following content to the paper.tex file: documentclass{article} begin{document} title{Sample Title} author{Author's Name} date{} % optional, add the date for this document here maketitle begin{abstract} The abstract text goes here. end{abstract} section{Section Title} Some text here. subsection{Title of a subsection} More text here cite{sample1}. section{Conclusion} Conclusion goes here. bibliographystyle{plain} bibliography{mybib} end{document}
  9. 9. 2. First Document - Bibliography file Add the following content to the mybib.bib file: @article{sample1, author = {Name, Surname}, title = {A nice paper}, journal = {A nice journal}, year = 2014, volume = {3} }
  10. 10. 3. Compiling the documents 1. Open the file paper.tex with your LaTeX editor 2. Use the editor build commands to generate the PDF ○ build once ○ then build the BibTeX index ○ build a second time ○ build a third time 3. Alternatively you can directly use the following commands: ○ pdflatex paper.tex ○ bibtex paper ○ pdflatex paper.tex ○ pdflatex paper.tex * It is necessary to build documents this way to make sure that the bibliography and the paper are properly synchronized. If this is not done properly, you will end up with undefined citations [?]
  11. 11. 3. Compiling the documents - the output The compiled PDF should look like this:
  12. 12. 4. Basic commands - document structure The document will be styled according to a particular class. Following the class, there will be a preamble and then the main body of the document. documentclass{template} % ...preamble, such as packages to import begin{document} % … body of the document end{document}
  13. 13. 4. Basic commands - comments Comments can be created using the % symbol. All the text after this symbol will be ignored. This is not a comment. % This is a comment and will be ignored.
  14. 14. 4. Basic commands - packages Extra functionalities might require you to import specific packages. To do this use the usepackage command as follows. Remember to use this command in the preamble: BEFORE the begin{document} command. usepackage{hyperref} For example, this package allows you to use the url command to properly output URLs: This is a url: url{http://www.w3.org/}.
  15. 15. 4. Basic commands - title Title, author and date, followed by the maketitle command title{Sample Title} author{Author's Name} date{5 November 2014} maketitle
  16. 16. 4. Basic commands - abstract The abstract should be enclosed by the following commands: begin{abstract} The abstract text goes here. end{abstract}
  17. 17. 4. Basic commands - sections Divide your text into sections using the following commands: section{Title of another section} Some text here. subsection{Title of a subsection} More text here. subsubsection{Title of a subsubsection} Even more text here.
  18. 18. 4. Basic commands - paragraphs To break your text into paragraphs, use the par command before a new paragraph. Another to create a new paragraph is to leave a blank line between two blocks of text. This is the text of the first paragraph. par And this text is in another paragraph. And this text is yet another paragraph.
  19. 19. 4. Basic commands - citations To make a citation, use the cite{} command. Within the brackets, give the citation-key of the BibTeX entry to cite. This is an example citation cite{sample1}.
  20. 20. 4. Basic commands - in-text references To make an in-text reference: 1. create labels using the label command 2. refer to them using the ref command section{First Section} The next will be Section ref{sectionlabel}. section{Second Section} label{sectionlabel} Some text.
  21. 21. 4. Basic commands - equations To create a numbered equation (which you can reference in the text), use the equation commands: begin{equation} label{equationlabel} alpha = sqrt{ beta } end{equation}
  22. 22. 4. Basic commands - in-line equations To create in-line equations, enclose the equation within $ symbols: This is an equation: $ 3x = 2y $, right?
  23. 23. 4. Basic commands - lists To create a list use the itemize command. Substitute itemize with enumerate to get an enumeration. begin{itemize} item First item item Second item item Third item end{itemize}
  24. 24. 4. Basic commands - tables Separate lines using the newline command Create horizontal lines using hline before the row to overline. Create vertical lines using the | symbol before the column definition (in this case the letter ‘l’ stands for ‘left aligned’) begin{table}[tp] centering begin{tabular}{ | l | l l } hline A & B & C hline a & b & c end{tabular} caption{Table caption here} label{sampletable} end{table}
  25. 25. 4. Basic commands - figures Figures (in this case Image.jpg) can be added using the following command. Images are one of many LaTeX objects which can have labels. begin{figure}[tb] centering includegraphics[width=1.00textwidth]{Image.jpg} label{figurelabel} caption{This is a figure} end{figure}
  26. 26. 4. Basic commands - bibliography 1. Choose the style of the bibliography using the bibliographystyle command. 2. Generate the bibliography using the bibliography command. bibliographystyle{plain} bibliography{mybib}
  27. 27. 5. Structure of the BibTeX file The BibTeX file is made of a set of entries. Each entry is made of ... @Book{abramowitz+stegun, author = "Milton {Abramowitz} and Irene A. {Stegun}", title = "Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables", publisher = "Dover", year = 1964, }
  28. 28. 5. Structure of the BibTeX file The BibTeX file is made of a set of entries. Each entry is made of a type (e.g. article, inproceedings, etc.) @Book{abramowitz+stegun, author = "Milton {Abramowitz} and Irene A. {Stegun}", title = "Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables", publisher = "Dover", year = 1964, }
  29. 29. 5. Structure of the BibTeX file The BibTeX file is made of a set of entries. Each entry is made of a citation key (you can choose any key you prefer) @Book{abramowitz+stegun, author = "Milton {Abramowitz} and Irene A. {Stegun}", title = "Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables", publisher = "Dover", year = 1964, }
  30. 30. 5. Structure of the BibTeX file The BibTeX file is made of a set of entries. Each entry is made of a set of fields @Book{abramowitz+stegun, author = "Milton {Abramowitz} and Irene A. {Stegun}", title = "Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables", publisher = "Dover", year = 1964, }
  31. 31. 5. Structure of the BibTeX file It is important to notice that each BibTeX type has a number of REQUIRED fields, and a number of optional ones. For example: article (i.e. a journal publication) ● required: author, title, journal, year ● optional: volume, number, pages, month, key, note inproceedings (i.e. a conference publication) ● required: author, title, booktitle, year ● optional: editor, volume/number, series, pages, address, month, organization, publisher, key, note
  32. 32. 6. Summary This short tutorial should have helped you getting started with LaTeX and BibTeX. For any problems you might encounter, and to use more advanced features, look at the vast amount of online resources, such as: http://en.wikibooks.org/wiki/LaTeX

×