Latex

Use latex !

Software

For Windows I recommend using MikTeX distribution, and TeXnicCenter which is an excellent latex editor (keyboard shortcuts etc).

With Linux I use TeTex distribution, and a normal text editor (Scite or Kate) or Kile which is a good latex editor (integrated compilation).

Howtos

To have all references as hyperlinks (table of contents, references, URLs) … You can also fill title and author fields of the pdf file.

\usepackage[colorlinks=true,urlcolor=blue,pdftitle={My report},pdfauthor={Cyril}]{hyperref}
 
\href{http://www.google.com}{Google's website}
\url{http://www.google.com}

Include PDF documents

Compile with pdflatex.

\usepackage{pdfpages}
\includepdf[pages=-]{pdf_filename_without_extension} % all pages

Highlight syntax in your code

\usepackage{listings}
 
% this is not mandatory (customization), after begin{document} :
\definecolor{colCode}{rgb}{.4,.4,.4}
\lstset{
language=[ANSI]C++, % default language
basicstyle=\footnotesize\ttfamily\color{colCode},
keywordstyle=\bfseries,
identifierstyle=,
commentstyle=\rmfamily\itshape\color{blue},
numbers=left, numberstyle=\tiny, stepnumber=5, numbersep=5pt,
showstringspaces=false,
tabsize=2,
extendedchars=true,
xleftmargin=.5cm
}
\begin{lstlisting}
for(int i = 0; i < 10; i++)
  cout << i << " " << endl;
\end{lstlisting}
 
\begin{lstlisting}[language=XML]
<foo bar=value>
hello
</foo>
\end{lstlisting}
 
\lstinputlisting{matlab.m} % include the file

Bibliography

\bibliographystyle{plain} % before begin{document}
 
\cite{gaussier99}
 
\nocite{*} % to print all references in the biblio without citing them
\bibliography{biblio}

In a file biblio.bib :

@BOOK{IA06,
  author = {Stuart Russel and Peter Norvig},
  publisher = {Pearson Education},
  title = {Artificial Intelligence},
  year = {2006}
}
 
@BOOKLET{gaussier99,
  author = {P. Gaussier, C. Joulain, J.P. Banquet, S. Leprêtre, A. Revel},
  title = {The visual homing problem},
  year = {1999}
}
 
@MANUAL{FAQCPP,
  title = {C++ FAQ Lite},
  author = {Marshall Cline},
  note = {Available on the Internet : http://www.parashift.com/c++-faq-lite/}
}

Then for compilation :

  1. [pdf]latex file.tex
  2. bibtex file
  3. [pdf]latex file.tex
  4. [pdf]latex file.tex

Annotations

To add some text that is viewed on the screen, but not printed.

The online version of this document contains additional information at
the end of this paragraph.
\pdfannot width 10em depth 50mm
  { /Subtype /FreeText
    /Contents (Hello, world!)}

Tips

Multirow entries in a table

\parbox[position][height][inner-pos]{width}{text}

For example :

\begin{tabular}[t]{cc}
short & still short\\
oh, short & \parbox[t][0.5cm]{4cm}{Oh this is really a very long sentence that I have to write in that cell now}\\
\end{tabular}

Number subsubsections with letters

\setcounter{secnumdepth}{3} % to number subsubsections
\renewcommand\thesubsubsection{\alph{subsubsection}} % to number them with just a letter
\makeatletter
\renewcommand\p@subsubsection{\thesubsection.} % to reference them with chap.sec.ssec.sssec
\makeatother

Errors

Texhash

When doing a texhash :

texhash: /usr/local/share/texmf/ls-R lacks magic string. Skipping...

The magic string is :

% ls-R -- filename database for kpathsea; do not change this line.

You must add it as the first line of the file /usr/local/share/texmf/ls-R

EDIT by cJ : You're sure of this ? I'm generating my ls-R with ls -R so I don't have this line, and kpathsea never complained … EDIT by cyril : all I know is that I had this error, there was no magic string, and after adding it texhash didn't complain anymore …

programming/latex.txt · Last modified: 2013/09/19 16:40 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki