Differenze

Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.

Link a questa pagina di confronto

Entrambe le parti precedenti la revisione Revisione precedente
Prossima revisione
Revisione precedente
vlsi:resources:latex:syntax [01/11/2013 13:51]
panati
vlsi:resources:latex:syntax [06/11/2013 23:44] (versione attuale)
panati
Linea 1: Linea 1:
-====== ​LaTex syntax quick references ======+====== ​LaTeX syntax quick references ======
  
 [ __[[vlsi:​home|Home]]__ ] [ __[[vlsi:​home|Home]]__ ]
 [ __[[vlsi:​resources:​latex|Back]]__ ] [ __[[vlsi:​resources:​latex|Back]]__ ]
- 
- 
  
  
Linea 12: Linea 10:
 % this is a comment % this is a comment
 </​code>​ </​code>​
- 
- 
  
  
Linea 29: Linea 25:
 \end{document} \end{document}
 </​code>​ </​code>​
 +
 +====== How to obtain a well organized source code ======
 +
 +It is possible to recall external parts of code in order to obtain a simpler and more clear structure of your main source code by using of the ''​\input{}''​ command.
 +
 +<​code>​
 +% Preamble:
 +\documentclass[options]{class type}
 +\usepackage{...}
 +...
 +
 +% body of your document
 +\begin{document}
 +
 +\input{section_01.tex} ​
 +\input{section_02.tex}
 +\input{section_03.tex}
 +...
 +\input{section_n.tex}
 +
 +\end{document}
 +</​code>​
 +
 +:!: Please note that in each .tex document (//​section_01.tex//,​ //​section_02.tex//​ etc.) you have __not to put__ any line just like ''​\begin{document}''​ or ''​\end{document}'',​ or packages'​ declarations:​ these are just //pieces of code// recalled in your text!!!
 +
  
  
Linea 73: Linea 94:
  
 LaTex supports **bold**, //italic// etc. LaTex supports **bold**, //italic// etc.
- 
  
 <​code>​ <​code>​
 LaTex supports \textbf{bold},​ \textit{italic} etc.  LaTex supports \textbf{bold},​ \textit{italic} etc. 
 </​code>​ </​code>​
- 
  
 You can also //​**combine** all these//, You can also //​**combine** all these//,
Linea 88: Linea 107:
  
 Note that ''​\textit{}''​ and ''​\emph{}''​ produce the same italic output. Note that ''​\textit{}''​ and ''​\emph{}''​ produce the same italic output.
 +
 +Other formats:
 +
 +<​code>​
 +\textsl{slanted text}
 +\texttt{typewriter text}
 +\textsc{small caps}
 +</​code>​
  
 ====== Sectioning ====== ====== Sectioning ======
  
 A document can be divided using chapters, sections, subsections,​ sub-subsections and paragraphs. A document can be divided using chapters, sections, subsections,​ sub-subsections and paragraphs.
- 
  
 <​code>​ <​code>​
-\chapter{name}+\part{name}
 </​code>​ </​code>​
  
Linea 101: Linea 127:
 \section{name} \section{name}
 </​code>​ </​code>​
- 
  
 <​code>​ <​code>​
Linea 111: Linea 136:
 </​code>​ </​code>​
  
 +<​code>​ 
 +\paragraph{name} 
 +</​code>​
  
 New paragraphs are automatically created by leaving an empty line. New paragraphs are automatically created by leaving an empty line.
 +
 +If you are using the ''​book''​ document class you can also use:
 +
 +<​code>​
 +\chapter{name}
 +</​code>​
  
 ====== Breaks ====== ====== Breaks ======
Linea 133: Linea 166:
 The ''​\clearpage''​ command is similar to ''​\newpage'',​ but  The ''​\clearpage''​ command is similar to ''​\newpage'',​ but 
 forces LaTex to print all folating tables and pictures before the page break. forces LaTex to print all folating tables and pictures before the page break.
- 
-<​code>​ 
-\vfill 
-</​code>​ 
- 
-The \vfill fill command produces a rubber length which can stretch or shrink vertically. It is equivalent to a blank line followed by \vspace\fill. 
  
 ====== Spacing ====== ====== Spacing ======
Linea 156: Linea 183:
 Usually you will specify spaces in ''​cm''​ or ''​mm'',​ but other typographic units exist. Usually you will specify spaces in ''​cm''​ or ''​mm'',​ but other typographic units exist.
  
 +<​code>​
 +\vfill
 +</​code>​
  
 +The \vfill fill command produces a rubber length which can stretch or shrink vertically. It is equivalent to a blank line followed by \vspace\fill.
  
 ====== Alignment ====== ====== Alignment ======
Linea 168: Linea 199:
 <​code>​ <​code>​
 \begin{flushright} \begin{flushright}
-... 
 ... ...
 \end{flushright} \end{flushright}
Linea 175: Linea 205:
 <​code>​ <​code>​
 \begin{flushleft} \begin{flushleft}
-... 
 ... ...
 \end{flushleft} \end{flushleft}
Linea 193: Linea 222:
 \begin{figure}[options] \begin{figure}[options]
  ​\centering  ​\centering
- ​\includegraphics[angle=-90,​ scale=0.80,​keepaspectratio=true]{pipe.jpg}+ ​\includegraphics[angle=-90,​scale=0.80,​keepaspectratio=true]{pipe.jpg}
  ​\caption{Ceci n'est pas une pipe - This is not a pipe (Magritte).}  ​\caption{Ceci n'est pas une pipe - This is not a pipe (Magritte).}
  ​\label{fig:​ pipe}  ​\label{fig:​ pipe}
Linea 220: Linea 249:
   * [[http://​www.guit.sssup.it/​downloads/​fig_tut.pdf|Gestione di Figure e Tabelle con LaTeX [IT]]]   * [[http://​www.guit.sssup.it/​downloads/​fig_tut.pdf|Gestione di Figure e Tabelle con LaTeX [IT]]]
   * [[http://​www.guit.sssup.it/​latex/​figure.php|Figure in LaTeX: una breve introduzione [IT]]]   * [[http://​www.guit.sssup.it/​latex/​figure.php|Figure in LaTeX: una breve introduzione [IT]]]
-  * [[http://​www.farstar.it/​latex/​immagini.php|Guida a LaTeX Immagini[IT]]]+  * [[http://​www.farstar.it/​latex/​immagini.php|Guida a LaTeX Immagini [IT]]]
   * [[http://​www.kwasan.kyoto-u.ac.jp/​solarb6/​usinggraphicx.pdf|How to Use the graphicx Package [EN]]]   * [[http://​www.kwasan.kyoto-u.ac.jp/​solarb6/​usinggraphicx.pdf|How to Use the graphicx Package [EN]]]
   * [[http://​en.wikibooks.org/​wiki/​LaTeX/​Floats,​_Figures_and_Captions|LaTeX/​Floats,​ Figures and Captions [EN]]]   * [[http://​en.wikibooks.org/​wiki/​LaTeX/​Floats,​_Figures_and_Captions|LaTeX/​Floats,​ Figures and Captions [EN]]]
Linea 226: Linea 255:
  
 ====== Tables ====== ====== Tables ======
 +
 +Simple tables:
 +
 +<​code>​
 +\begin{tabular}{|l|c|r|} % '​l'​ is for '​left',​ '​c'​ is for '​center',​ '​r'​ is for '​right'​
 +\hline
 + first & second & third \\
 +\hline
 + 1 & 2 & 3 \\
 +\hline
 +\end{tabular}
 +</​code>​
 +
 +See also:
 +  * [[http://​mnnugm.altervista.org/​latex/​Tabelle.pdf|Tabelle con LaTeX [IT]]]
 +  * [[http://​wwwcdf.pd.infn.it/​AppuntiLinux/​a2550.htm|LaTeX:​ tabelle [IT]]]
 +  * [[http://​www.guit.sssup.it/​downloads/​fig_tut.pdf‎|Gestione di Figure e Tabelle con LATEX - GuIT [IT]]]
 +  * [[http://​www.lorenzopantieri.net/​LaTeX_files/​TabelleRipartite.pdf|L'​arte di ripartire una tabella su più pagine con LaTeX [IT]]]
 +  * [[http://​www.tug.org/​pracjourn/​2007-1/​mori/​mori.pdf‎|Tables in LaTeX: packages and methods [EN]]]
 +  * [[http://​en.wikibooks.org/​wiki/​LaTeX/​Tables|LaTeX/​Tables (WikiBooks) [EN]]]
  
 ====== Math formulas ====== ====== Math formulas ======
  
-====== ​Graphs ======+If you want to obtain some mathematical text without using some special packages directly in your text: 
 + 
 +<​code>​ 
 +$ e^{i\pi}+1=0 $  
 +</​code>​ 
 +  
 +<​code>​ 
 +\begin{math} \vec{F} ​m \vec{a}\end{math} 
 +</​code>​ 
 + 
 +<​code>​ 
 +\S \int{L \: dt} \) 
 +</​code>​ 
 + 
 +<​code>​ 
 +$ \lim_{x \rightarrow \infty} \frac{\sin{x}}{x} ​1 $ 
 +</​code>​ 
 + 
 +... or in a different text block: 
 + 
 +<​code>​ 
 +\begin{displaymath}e^{i\pi}+1=0 \end{displaymath} 
 +</​code>​ 
 + 
 +<​code>​ 
 +\[\vec{F} ​m \vec{a}\] 
 +</​code>​ 
 + 
 +<​code>​ 
 +$$S \int{L \: dt} $$ 
 +</​code>​ 
 + 
 +... or in a different block of text with the number of the equation flagged: 
 + 
 +<​code>​ 
 +\begin{equation}\lim_{x \rightarrow \infty} \frac{\sin{x}}{x} ​1 \end{equation} 
 +</​code>​ 
 + 
 + 
 + 
 +Some utilities:​ 
 +  * [[http://​www.codecogs.com/​latex/​eqneditor.php|LaTeX Equation online generator]] 
 +  * [[http://​www.texify.com/​|TeXify]] 
 + 
 +See also: 
 +  * [[http://​kogler.wordpress.com/​2008/​03/​21/​latex-multiline-equations-systems-and-matrices/​|Multiline equations, matrices, etc. [EN]]] 
 +  * [[http://​www.math.tamu.edu/​~harold.boas/​courses/​math696/​LaTeX-formatting-equations.html|Formatting equations in LaTeX [EN]]] 
 +  * [[ftp://​ftp.ams.org/​ams/​doc/​amsmath/​short-math-guide.pdf|Short Math Guide for LaTeX [EN]]] 
 +  * [[http://​www.guit.sssup.it/​arstexnica/​download_ars/​articoli_ars_08/​Simboli%20matematici%20in%20TEX%20e%20LATEX.pdf|Simboli matematici in TeX e LaTeX [IT]]] 
 +  * [[http://​wwwcdf.pd.infn.it/​AppuntiLinux/​a2552.htm|LaTeX:​ ambienti matematici [IT]]]
  
 ====== Coding ====== ====== Coding ======
 +
 +If you want to add some code listings into your text you can use the ''​listings''​ package putting
 +
 +<​code>​
 +\usepackage{listings}
 +</​code>​
 +
 +in your preamble. Then you can define some setting for your code; for instance:
 +
 +<​code>​
 +\lstset{
 +language=VHDL,​
 +numbers=left,​
 +numberstyle=\tiny,​
 +stepnumber=1,​
 +basicstyle=\small\ttfamily,​
 +keywordstyle=\color{red}\bfseries,​
 +commentstyle=\color{blue},​
 +stringstyle=\color{green},​
 +showstringspaces=false}
 +</​code>​
 +
 +The listings package supports highlighting of all the most common languages and it is highly customizable.
 +
 +<​code>​
 +\begin{lstlisting}[frame=lines]
 +entity eqcomp is
 +  port (a, b: in bit_vector (3 downto 0);
 +  eq, neq : out bit);
 +  end eqcomp;
 + 
 +architecture dataflow of eqcomp is
 +  signal aux1 : bit;
 +  begin
 +  neq <= not aux1; -- low active
 +  aux1 <= ‘1’ when (a = b) else ‘0’;
 +  eq <= aux1;
 + end dataflow;
 +\end{lstlisting}
 +</​code>​
 +
 +You can find [[http://​en.wikibooks.org/​wiki/​LaTeX/​Source_Code_Listings#​Supported_languages|here]] the complete list of the supported languages.
 +
 +See also:
 +  * [[http://​www.lorenzopantieri.net/​LaTeX_files/​Codici.pdf|L'​arte di scrivere codici con LaTeX [IT]]]
 +  * [[ftp://​ftp.tex.ac.uk/​tex-archive/​macros/​latex/​contrib/​listings/​listings.pdf|The Listings Package [EN]]]
 +  * [[http://​kar2905.wordpress.com/​2010/​03/​23/​installing-listings-package-for-latex/​|Installing Listings Package for LaTeX]]
 +  * [[http://​en.wikibooks.org/​wiki/​LaTeX/​Source_Code_Listings|LaTeX/​Source Code Listings (WikiBooks) [EN]]]
 +  * [[http://​www.ctan.org/​pkg/​listings|CTAN listings – Typeset source code listings using LATEX [EN]]]
  
 ====== Non-formatted text ====== ====== Non-formatted text ======
Linea 243: Linea 390:
 \end{verbatim} \end{verbatim}
 </​code>​ </​code>​
 +
 +====== Graphs ======
 +
 +See:
 +  * [[http://​www.math.ufl.edu/​~mgluck/​GraphingInLatex.pdf|Graphing in LATEX using PGF and TikZ]]
 +  * [[http://​www.grad.iit.edu/​latex/​LaTeX/​FigureHelp1.pdf|Creating Figures and Graphs with LaTeX]]
 +  * [[http://​www.texample.net/​tikz/​examples/​tag/​graphs/​|Examples]]
  
 ====== Feynman diagrams ====== ====== Feynman diagrams ======
  
 +See:
 +  * [[http://​adamgetchell.blogspot.it/​2012/​09/​feynman-diagrams-in-latex.html|Feynman diagrams in LaTeX]]
 +  * [[http://​xml.web.cern.ch/​XML/​textproc/​feynmf.html|Drawing Feynman Diagrams with LaTeX and METAFONT (or METAPOST)]]
 +  * [[http://​www.fi.infn.it/​pub/​tex/​doc/​orig/​fmfman.pdf|Drawing Feynman Diagrams with LATEX andMETAFONT]]
 +  * [[http://​osksn2.hep.sci.osaka-u.ac.jp/​~taku/​osx/​feynmp.html|feynMF/​feynMP - Drawing Feynman Diagram]]
 +  * [[http://​osksn2.hep.sci.osaka-u.ac.jp/​~taku/​osx/​fmfsamples.pdf|Examples]]
  
 ====== Table of contents ====== ====== Table of contents ======
Linea 261: Linea 421:
 Other similar commands are ''​\listoftables''​ and ''​\listoffigures''​ which produce a list of tables (LOT) Other similar commands are ''​\listoftables''​ and ''​\listoffigures''​ which produce a list of tables (LOT)
 and a list of figures (LOF) respectively. and a list of figures (LOF) respectively.
 +
 +====== Supported Languages ======
 +
 +<​code>​
 +\usepackage[languages]{babel}
 +</​code>​
 +
 +<​code>​
 +\selectlanguage{choosenlanguage}
 +</​code>​
 +
 +i.e.
 +
 +<​code>​
 +\usepackage[italian,​ english]{babel}
 +</​code>​
 +
 +
 +<​code>​
 +\selectlanguage{english}
 +</​code>​
 +
 +
  
 ====== Numerical references ====== ====== Numerical references ======
Linea 347: Linea 530:
 ---- ----
  
-Last update: [[pacher@NOSPAMto.infn.it|Luca pacher]] - Oct 27, 2013+Last update: [[panati@to.infn.it|Serena Panati]] Nov 6th, 2013 //
  
 ~~NOTOC~~ ~~NOTOC~~