Monday, December 16, 2013

how to write naiive

na\"\i ve

 Works for me

How to number several equations with one number

\begin{eqnarray} 
 \begin{array}{rl}
    &x = foo \\
    & y = bar
 \end{array}
\end{eqnarray}
 I sometimes get that I should not use eqnarray that extensive, but it works for me.
Another solutions with equation and aligned environments here.

Tuesday, October 15, 2013

diff LaTeX documents

This is a great stuff to diff latex docs:

http://www.ctan.org/tex-archive/support/latexdiff

you might also be able to install it for your ubuntu for instance using

$ sudo aptitude install latexdiff

Usage:

$ latexdiff old.tex new.tex > diff.tex

This will create a new file called diff.tex, which is a valid LaTeX document countaining the difference between the two, if old.tex and new.tex were also valid LaTeX docs, and you can proceed diff.tex as you normally would creating eps, pdf, html, etc ...

If you don't want to or can't install the tool, it's available online here:
http://3142.nl/latex-diff/

If you are using version control like svn or cvs, you might consider using the latexdiff-vc command, that actually makes the diff from the version in the version control. More resources about this you can find at the links below:

http://kwtrnka.wordpress.com/2010/11/28/latexdiff-version-control/  

http://www.jwe.cc/2012/02/workflow-with-subversion-and-latex/ 

For example I use

 $ latexdiff-vc --svn -r <oldversion> --pdf <mylatex.tex>
in order to generate pdf diff in one step

Tuesday, August 27, 2013

How to convert latex to M$ office / openoffice readeable

The easiest and best solution I found so far to do this (under linux) is the method on
http://ubuntuforums.org/archive/index.php/t-1033441.html
Using htlatex

latex foo.tex
latex foo.tex
latex foo.tex
htlatex foo.tex
 This then will create a relatively good looking html, that can be read under soffice for instance and convert to doc / docx, etc...
This converts the equations to figures, and the layout could be better, but it works fine.

Another option is to use the  tex2rtf package
http://www.ctan.org/pkg/tex2rtf
This one generates an .rtf file, but the result on my files were not that good, and the equations were a disaster, and can not handle eps figures (pslatex)...

Wednesday, July 31, 2013

How to cite section of a paper or chapter a book

For section of a book you can add reference of type @inbook to bibtex, but for my purposes it is usually easier to cite using
\cite[section~1.1]{foo}
 this way you can for instance cite several parts / sections / chapters from the same book or paper.

Thursday, June 20, 2013

Makefile for LaTeX

Sometimes it is very useful to have standardized ways to compile documents. I use vim to edit LaTeX source, and I was looking for makefile for LaTeX for a while, when I found this project:

http://code.google.com/p/latex-makefile/downloads/detail?name=latex-makefile-2.2.0.tar.gz

Simply copy the Makefile in the directory on your linux system and type

$make
 Works perfectly for me for creating the pdf from the surce.

Monday, June 17, 2013

How to write citations on the right side on beamer

Sometimes when you cite (repeat) entire parts or figures of cited work in presentation it is advisable to write a citation on the right bottom corner  of the slide. This can be done as:
 \begin{flushright}
    \cite{mypaper}
\end{flushright}

How to make two colums horisontally on LaTeX beamer slides

The easiest way to do this is to use \column as

 \begin{columns}[cc]
 \column{0.5\textwidth}
    some content ...
 \column{0.5\textwidth}
    some more content
\end {columns}

Tuesday, April 30, 2013

How to convert all eps files to pdf in a directory

If you just want to convert a single file, you can use epstopdf <file>
as described here

Sometimes I need to convert all the eps files to pdf, for instance because I use latexpdf and I have all the images in eps. Here is a short linux bash script that does the job.


#/usr/bin/bash
for file in *.eps
do
  epstopdf $file
done

This I have in a script file in the path. Don't forget to install the ghostscript package to be able to use epstopdf command.

Or another solution is using the find command:

 $ find . -name "*.eps" -exec epstopdf {} \;

as described in  http://www.linuxquestions.org/questions/linux-newbie-8/using-multiple-epstopdf-command-854618/

Monday, April 1, 2013

How to write the set of real numbers

For an n dimensional vector I use
$\mathbb{R}^n$
Do not forget to include the amssymb or amsfonts package
Similarly \mathbb{Z} for integer, \mathbb{N} for natural and \mathbb{C} for complex and so on...

Sunday, March 31, 2013

Monday, March 18, 2013

Writing macros, defining new commands

New commands can be defined as 

\newcommand{\newtag}{your new command}
 If you would like to pass arguments to the command it is possible as
\newcommand{\newtag}[1]{your new command, your argument is {#1}}

How to change background color of enumeration

See the answer here:
http://www.latex-community.org/forum/viewtopic.php?f=44&t=13447&p=50828

Fractions in latex

The easiest way to write fractions in an equation is to use the \frac command as
\frac{a}{b}

Tuesday, March 5, 2013

Write transpose of a matrix

Transpose of a matrix (switching rows with columns), I like to write with "T" in exponent, where the exponent is not italic, like 
$A^{\rm T}$

Thursday, February 28, 2013

How to write tilde and backslash in Latex

Here is a good description about the topic:

http://tex.stackexchange.com/questions/9363/how-does-one-insert-a-backslash-or-a-tilde-into-latex

How to write Ordo for complexity in latex

Ordo (or the big-O notation) is used to describe computational complexity, in technical writing. I found the best way to write it is 
$\mathcal{O}(x^2 + ...)$

How to use .tiff figures in MATLAB

Well, I was digging deep, and this issue does not seem to be solved :(
The best thing to do is to use png, pdf or eps instead.
When using linux the imagemagick package can be used for example as

$ convert myfile.tif myfile.pdf

Multirow and multicolumn tables

Joining rows and columns  in LaTeX tables is really easy using the multirow package. For details see

http://en.wikibooks.org/wiki/LaTeX/Tables


http://www.andrewjpage.com/index.php?/archives/43-Multirow-and-multicolumn-spanning-with-latex-tables.html

Thursday, January 31, 2013

Writing signature in latex documents

Some documents need to be signed by hand, leaving an empty line for the signature and writing the name underneath here is  the solution that worked for me:

First define a new command at the beginning of your document as
\newcommand{\signature}[2][5cm]{
  \begin{tabular}
  {@{}p{#1}@{}}
    \hrule \\[0.05cm]
    \centering{#2}
  \end{tabular}
}

Then use it at the end of the document for instance as

 \flushright\noindent \signature{Firstname Lastname}