Latex Parte III


Modifying text styles
To modifying some text, to make it italic, bold..., we need to add a tag, like in the next examples.
  • To insert bold text, use \textbf{text here}
  • To insert italic text, use \emph{text here}
  • To insert monospace text, use \texttt{text here} 
  • To use verbatim text within a sentence, use \verb|your text here|.Note: any delimiter can be used.



Figures and tables
Figures and tables are LaTeX environments, however the final position of the elements depends on the latex's style algorithm, thats why they are called float elements.
Figures
To insert a figure, use
\begin{figure}[hbtp]
\caption{Figure name}
\begin{center}
\includegraphics{filename.pdf}
\end{center}
\label{your-reference-key}
\end{figure}
In the above markup,
  • \begin{figure} tells that is a figure environment
  • [hbtp] tells how LaTeX will place the figure :
    • (here (h), bottom (b), top(t), page(p)). 
    • If the current space where the figure is called, don't have space, it will be placed in the next page, if you want to force the location, simple choose \begin{figure}[h], omitting b, p and t. The order in which h,b,t and p are specified determines where LaTeX tries to place the float first.
  • \caption{Figure name} name of the figure
  • \begin{center} tells to center the figure in the document. Note: don't forget to close the tag center.
  • \includegraphics{…} location of the file
  • \label{your-reference-key} is a label that you can use to refer to the figure in the text. For example, if you label your figure “fig1″ then you can reference it later on by typing \ref{fig1}


Tables
A floated table in LaTeX consists of two environments: table, the actual floated entity in the text, and tabular, the data contained in the table. For example, 




\begin{tabular}{|c|c|}
\hline BIT & Significado se igual a 1 \\
\hline URG & O campo Urgent Pointer È v·lido \\
\hline ACK & O campo Acknowledgement Number È v·lido \\
\hline PSH & Este segmento pede um push \\
\hline RST & Reinicia a comunicaÁ„o \\
\hline SYN & Sincroniza os n˙meros de sequÍncia \\
\hline FIN & O emissor chegou ao fim do fluxo de informaÁ„o \\
\hline
\end{tabular}



everything except the code between \begin{tabular} … \end{tabular} is the same as the figure. Here’ s how the
tabular environment works:
  • \begin{tabular}{c|cc} tells LaTeX to start a new tabular environment with two centered columns. The bar (“|”) after the first “c”, tells that have a vertical border. We can use {lcrr} to create columns: 
    • the first left aligned, the second centered, and the third and fourth right aligned
  • The table cells are separated by a “&” and the table rows are separated by a “\\”

This is not the the table example, but can be also used in the tables.
  • The \hline creates a horizontal line
  • \multicolumn{2}{c}{Example} creates a row that spans all two columns, and gonna be centered, and contains the text “Example”
  • There are more options, but this is allmost what you need to create tables.





Annotations
In LateX we can import some annotations, footnotes, references, table of contents, and bibliographies.
Footnotes
To insert a footnote, we just have to insert  \footnote{Footnote text here}.
Cross references
To insert a reference on a table or figure, we just have to type \ref{your-reference-key} where “your-reference-key” is the argument to the \label{your-reference-key} command.




Table of contents
To insert a table of contents, simply put \tableofcontents at the beginning of your document. (You must run LaTeX twice to get the table of contents and references to work correctly.

Bibliography
To create a bibliography,we just have to use the next form:
\begin{thebibliography}{99}
….
\bibitem{key1} Disarray, General. 2006. “\LaTeX{}: from beginner to \TeX pert.” \emph{General Disarray Blog}. Available online at \textt{http://generaldisarray.wordpress.com}. ….
\end{thebibliography}
We have to type he bibliography entry, and to refer a item we must use \cite{key}. The {99} tells that the maximum is 99 entries in the bibliography.
To build the bibliography we can use bibTex, is more efficient to build one, so we dont have to hardcode the references.

An website that helps a lot in latex is http://aprendolatex.wordpress.com/, is in portuguese, but have a lots of exemples to improve your latex documents


Sources: http://generaldisarray.wordpress.com/2006/04/20/latex-from-beginner-to-texpert/

0 comentários:

Enviar um comentário