Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
programming:latex [2006/12/14 01:54]
cyril created
programming:latex [2013/09/19 16:40] (current)
Line 2: Line 2:
  
 Use latex ! Use latex !
 +
 +===== Software =====
 +
 +For Windows I recommend using [[http://www.miktex.org/|MikTeX]] distribution, and [[http://www.toolscenter.org/|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 =====
 +==== Use hyperlinks ====
 +
 +To have all references as hyperlinks (table of contents, references, URLs) ...
 +You can also fill title and author fields of the pdf file.
 +
 +<code latex>
 +\usepackage[colorlinks=true,urlcolor=blue,pdftitle={My report},pdfauthor={Cyril}]{hyperref}
 +
 +\href{http://www.google.com}{Google's website}
 +\url{http://www.google.com}
 +</code>
 +
 +
 +
 +==== Include PDF documents ====
 +
 +Compile with ''pdflatex''.
 +
 +<code latex>
 +\usepackage{pdfpages}
 +\includepdf[pages=-]{pdf_filename_without_extension} % all pages
 +</code>
 +
 +==== Highlight syntax in your code ====
 +
 +<code latex>
 +\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
 +}
 +</code>
 +
 +<code latex>
 +\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
 +</code>
 +
 +
 +
 +==== Bibliography ====
 +
 +<code latex>
 +\bibliographystyle{plain} % before begin{document}
 +
 +\cite{gaussier99}
 +
 +\nocite{*} % to print all references in the biblio without citing them
 +\bibliography{biblio}
 +</code>
 +
 +In a file ''biblio.bib'' :
 +<code latex>
 +@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/}
 +}
 +</code>
 +
 +Then for compilation :
 +  - [pdf]latex file.tex
 +  - bibtex file
 +  - [pdf]latex file.tex
 +  - [pdf]latex file.tex
 +
 +==== Annotations ====
 +
 +To add some text that is viewed on the screen, but not printed.
 +
 +<code latex>
 +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!)}
 +</code>
 +
 +===== Tips =====
 +
 +==== Multirow entries in a table ====
 +
 +<code latex>
 +\parbox[position][height][inner-pos]{width}{text}
 +</code>
 +
 +For example :
 +<code latex>
 +\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}
 +</code>
 +
 +==== Number subsubsections with letters ====
 +
 +<code latex>
 +\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
 +</code>
 +===== 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.1166061297.txt.gz · Last modified: 2013/09/19 16:43 (external edit)
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0