UPC LaTeX Template¶
Welcome to UPC LaTeX Template, a simple and yet powerfull LaTeX template developed for UPC students willing to create and easy-to-use and yet fancy documents.
This includes, everything you need to handle during your career.
We use Pandoc to handle the conversion between markdown or restructuredText into PDF
What is LaTeX?¶
LaTeX is a document preparation system for high-quality typesetting. It is most often used for medium-to-large technical or scientific documents but it can be used for almost any form of publishing.
LaTeX is not a word processor! Instead, LaTeX encourages authors not to worry too much about the appearance of their documents but to concentrate on getting the right content.
So we took a bit of timing to take care of the design, changing things to make them look like the official documents provided on UPC
What is a template?¶
Pandoc make use of LaTeX templates to design your pdf, so in fact our template is a preset configuration to ensure your document meets the line between a fancy document and powerful one.
Note
This site is NOT part of Polytechnic University of Catalonia, it’s just a free time developed project made by students
Installation¶
Installing the templates takes only a few steps, you can use the template in diferent ways, but we’ll show how to add it as the default pandoc template
Prerequisites¶
You’ll need to have pandoc installed (linux - Debian / Ubuntu):
To use the full features of pandoc, please install the version 1.16, not the 1.12 that comes with ubuntu
RECOMMENDED Version 1.17:
NOT RECOMMENDED Version 1.12:
sudo apt-get install pandoc
Download for Windows
You’ll also need to install LaTeX (linux - Debian / Ubuntu):
sudo apt-get install texlive
For other operating systems, please take a closer look at pandoc installation page:
Installing¶
Once the file has been downloaded you’ll need to place the files under the pandoc default folder.
To see where the folder is located, you can type the following in your terminal:
pandoc -v
This will give you a list of information about pandoc, you just need to get the default folder location, here’s an example output:
Default user data directory: /home/erik/.pandoc
You will then need to place the files provided in the download section in your home folder, creating the .pandoc folder if it did not exist.
The template file should then be available under the following location (example):
/home/erik/.pandoc/templates/default.latex
If everything went well you should then have the template installed and ready to go, take a look at the getting started page to learn how to use it.
Updating¶
To update the template, simply run the python script in the .pandoc folder like follows:
Note: Python 2.7 Required
python update.py
Getting Started¶
This page will guide you the basics of using pandoc with our template.
The usage is not diferent than any other pandoc command, the reason is that the template provided works as a default template for any pdf conversion using latex.
The full list of commands may be found here
All the following examples will assume you have a file named test.md in the working directory
Creating a PDF¶
To create a PDF, simple type the following in your terminal
pandoc test.md -o test.pdf
This command will use the template and create a PDF called test.pdf based on the test.md file (Markdown)
Or if you’re using rst:
pandoc test.rst -o test.pdf
This command will use the template and create a PDF called test.pdf based on the test.rst file (reStructuredText)
Creating the front page¶
We provide a simple yet powerful way to create the front page for your documents.
To do such, you just need to add pandoc’s YAML meta data on the document’s heading (before any other text) for example, a document with the following data:
---
title: Pràctica 0 - Teoria De Circuits
subtitle: Mesures al Laboratori
author:
- Èrik Campobadal
- Roger Solans
- Aleix Gil
---
This will create a simple front page for your document, and clear the page after it.
At the same time, the page will not contain any number and will not be counted towards page numering.
NOTE You can create another file called meta.yaml and place the yaml data there and then call it when converting:
pandoc test.md meta.yaml -o test.pdf
WARNING Pandoc YAML metadata is only available in markdown (.md), if you use other markups such as .rst you’ll need to provide the information in the command line
Example:
pandoc test.rst -o test.pdf -V title:'My Project Title' -V subtitle:'My Custom Subtitle' -V toc:true -V autodate:true
Front Page Logo¶
To se the front page logo you can use the following meta data:
logo: true
To define a custom logo simply add the image to the images folder in your data directory (in my example):
/home/erik/.pandoc/images
Add the images to that path and then you can get them the following way (example image: test.png in my images folder on my data dir):
logo-image: test
logo-height: 2
logo-width: 2
The image height / width is set in cm
The image extension (.png) is ommited, you can google the supported image types for LaTeX)
Creating a Table Of Contents¶
To create a table of contents you’ll just need to provide an extra meta data:
toc: true
toc-title: Contents
toc-depth: 3
numbersections: true
You can optionaly choose if you would like to change the default title, by default it’s: Continguts
You can optionaly choose if you would like them to have a number.
The toc-depth specifies the level of section to include in table of contents
Additional Meta Data¶
Some additional data you might use in your documents:
Dates
You can include the date in your front page with the following meta data:
date: false
autodate: true
You can also set an autodate variable to set the day at the day the document it’s compiled (recommended)
Abstract
You can include an abstract in your document, that will be placed in the front page
abstract: This is my abstract
Includes
You can handle the includes in the following way:
include-before: Contents included before body (may have multiple values)
include-after: Contents included after body (may have multiple values)
Other LaTeX Variables¶
papersize
paper size, e.g. letter, A4
fontsize
font size for body text (e.g. 10pt, 12pt)
documentclass
document class, e.g. article, report, book, memoir
classoption
option for document class, e.g. oneside; may be repeated for multiple options
geometry
option for geometry package, e.g. margin=1in; may be repeated for multiple options
margin-left, margin-right, margin-top, margin-bottom
sets margins, if geometry is not used (otherwise geometry overrides these)
linestretch
adjusts line spacing using the setspace package, e.g. 1.25, 1.5
fontfamily
font package for use with pdflatex: TeX Live includes many options, documented in the LaTeX Font Catalogue. The default is Latin Modern.
fontfamilyoptions
options for package used as fontfamily: e.g. osf,sc with fontfamily set to mathpazo provides Palatino with old-style figures and true small caps; may be repeated for multiple options
mainfont, sansfont, monofont, mathfont, CJKmainfont
font families for use with xelatex or lualatex: take the name of any system font, using the fontspec package. Note that if CJKmainfont is used, the xecjk package must be available.
mainfontoptions, sansfontoptions, monofontoptions, mathfontoptions, CJKoptions
options to use with mainfont, sansfont, monofont, mathfont, CJKmainfont in xelatex and lualatex. Allow for any choices available through fontspec, such as the OpenType features Numbers=OldStyle,Numbers=Proportional. May be repeated for multiple options.
fontenc
allows font encoding to be specified through fontenc package (with pdflatex); default is T1 (see guide to LaTeX font encodings)
colorlinks
add color to link text; automatically enabled if any of linkcolor, citecolor, urlcolor, or toccolor are set
linkcolor, citecolor, urlcolor, toccolor
color for internal links, citation links, external links, and links in table of contents: uses any of the predefined LaTeX colors
links-as-notes
causes links to be printed as footnotes
indent
uses document class settings for indentation (the default LaTeX template otherwise removes indentation and adds space between paragraphs)
subparagraph
disables default behavior of LaTeX template that redefines (sub)paragraphs as sections, changing the appearance of nested headings in some classes
thanks
specifies contents of acknowledgments footnote after document title.
toc
include table of contents (can also be set using –toc/–table-of-contents)
toc-depth
level of section to include in table of contents
lof, lot
include list of figures, list of tables
bibliography
bibliography to use for resolving references
biblio-style
bibliography style, when used with –natbib and –biblatex.
biblatexoptions
list of options for biblatex.
Quick Guide¶
Some quick guide to see how pandoc works under the markdown document
NOTE: This guide is written for markdown
Centering Text¶
To center some text, just type the following anywhere in your markdown code:
\begin{center}
Some centered text
\end{center}
Images¶
To include images, use the following:
{width=50%}
This will include an image and use 50% of the document width (add a final to create an inline image)
Tables¶
Table generator site
To create simple tables, simply use the following example:
| Test Table | This a test table | Some other field |
|----------------|-------------------|------------------|
| Random value | Random value | Random value |
| Some more text | Some more text | Some more text |
Bold & italic¶
Bold
**I'm bold**
Italics
*I'm italic*
Links¶
To create simple liks (and make them clickable) just add the following:
<http://google.com>
Another way is telling the link text:
[This link](http://example.net/)
Lists¶
To define lists, simply do the following:
Bullet lists:
- One - Two
Numbered lists
1. Number 1 2. Number 2
Code Block¶
To add a code block, simply type the code in the following way
```
Code Here
```
If you need to syntax highlight it:
```python
s = "Python syntax highlighting"
print s
```
```Vhdl
Vhdl code
```
Mathematics¶
You can use diferent maths operations with pandoc, here you might get the idea of how they are done
For more information, check Maths
Markdown, LaTeX, Emacs Org mode, ConTeXt¶
You can create Mathematical formulas and operations using Pandoc, to do such simple type the formula like this:
$(a + b)$
You’ll need to phrase all the mathematical formulas leaving a blank space on the left before the first $ and a blank space on the right in the last $
You can of course, use signs and other variables, to do such, simply take a look at this PDF, it contain a list of usefull signs that can be used inside the $ $
Another source with usefull signs: Here
A quick example:
$3 \pi r$
Will be translated into 3PIr with the PI sign.
Another example:
$\pi \cdot R^{2}$
This will be translated into PI * R^2
Better Usage¶
The best way to use the formulas is the following:
$$
(a + b) \cdot \pi + \int_0^5{2x}
$$
This will center the formula and at the same time make it in a new line, so it will have better space and will be better to look at.
reStructuredText¶
The syntax it’s diferent, you can use:
:math:`A_\text{c} = (\pi/4) d^2`.
This will create the correct maths text.
Raw LaTeX Code¶
Pandoc allows raw LaTeX, TeX, and ConTeXt to be included in a document. Inline TeX commands will be preserved and passed unchanged to the LaTeX and ConTeXt writers. Thus, for example, you can use LaTeX to include BibTeX citations:
This result was proved in \cite{jones.1967}.
Note that in LaTeX environments, like
\begin{tabular}{|l|l|}\hline
Age & Frequency \\ \hline
18--25 & 15 \\
26--35 & 33 \\
36--45 & 22 \\ \hline
\end{tabular}
The material between the begin and end tags will be interpreted as raw LaTeX, not as Markdown.
Inline LaTeX is ignored in output formats other than Markdown, LaTeX, and ConTeXt.
License¶
UPC LaTeX Template is under the following license
The MIT License (MIT)¶
Copyright (c) 2016 Erik Campobadal
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.