Pages

Affichage des articles dont le libellé est latex. Afficher tous les articles
Affichage des articles dont le libellé est latex. Afficher tous les articles

mardi 22 avril 2014

use longtable in Latex

When I have a very long table which can occupy several pages, I need the package longtable for breaking the table and manage it.

When use this package, then we should not use the table package, ie., not to start by \begin{table}. The longtable should also replace the tabular. Then we can add caption and label in the following. We can start for example:
\begin{center}
\begin{longtable} {cccc}
\caption{Captions.}\\
\label{label name.}\\

If we want to adjust the table fontsize, we can:
 \begin{center}
\small{
\begin{longtable} {cccc}
\end{longtable}
}
\end{center}

If we want the same head line to appear in the table in the different pages, then we should for example define the head line of table in the first page:
FTLRS  &a &b  &   &MOBLAS-8 &a  &b \\  \hline
\endfirsthead

Then we need define the head line of table in the next pages:
FTLRS &a &b  & & MOBLAS-8 &a &b \\ \hline

\endhead

A complete example of using longtable is:
\documentclass{article}
\usepackage{longtable}
 \begin{document}

 \begin{center}
 \small{
   \begin{longtable} {ccccccc}
   \caption{Captions.} \\
   \label{label name} \\

  
   FTLRS &a &b  & &MOBLAS-8 & a &b \\ \hline   

   \endfirsthead

   FTLRS & a & b  &   & MOBLAS-8 & a & b \\ \hline   
   \endhead

   data1 & d1 &d2 &   &   data2 & d3 &d4 \\
   ....
   ...
   \end{longtable}
 }
\end{center}


 






Latex error: extra alignment tab has been changed to \cr

This is often caused by the inconsistency between the number of columns given in \begin{tabular}{ccc} and that given in the actual lines of the table.

If there is not inconsistency between them, then it is probably caused by the forgetting of \\ in the previous row.

vendredi 13 septembre 2013

include accent, comments in latex file


1) for including accents in latex file:
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern} 

Then we can type the characters directly into your source file.

2) for including the comments at the side of document, a good tool is todonotes.
\usepackage{todonotes}
\begin{document}
Here is the document.  
\todo[color=green!40] {Here are some comments}.

\end{document}

mercredi 24 avril 2013

install natlib in mac

Install :
1) kpsewhich -var-value TEXMFHOME
--- /Users/username/Library/texmf
2) Download the natlib from CTAN to /Users/username/Library/texmf/tex/natlib
3) Dowload the natlib.sty to /Users/username/Library/texmf/latex
3) sudo texhash
4) pdflatex file.tex
    bibtex file.aux
    pdflatex file.tex
    pdflatex file.tex


In the file.tex:
\usepackage[square]{natbib}
\bibpunct{(}{)}{,}{a}{}{,}

\bibliographystyle{plainnat}
\bibliography{myref}
Note: the myref is the myref.bib which contains the references.

In the file myref.bib:
The format should be correct. For example:


@article{itrf2008,
year={2011},
issn={0949-7714},
journal={Journal of Geodesy},
volume={85},
number={8},
doi={10.1007/s00190-011-0444-4},
title={ITRF2008: an improved solution of the international terrestrial reference frame},
url={http://dx.doi.org/10.1007/s00190-011-0444-4},
publisher={Springer-Verlag},
keywords={Reference systems; Reference frames; ITRF; Earth rotation},
author={Altamimi, Zuheir and Collilieux, Xavier and Métivier, Laurent},
pages={457-473},
language={English}
}

Get the bibtex format of the paper either through http://adsabs.harvard.edu/, or through the journal website.

mardi 15 janvier 2013

line/paragraph breaking in latex


  • \\ start a new paragraph.
  • \\* start a new line but not a new paragraph.
  • \- OK to hyphenate a word here.
  • \cleardoublepage flush all material and start a new page, start new odd numbered page.
  • \clearpage plush all material and start a new page.
  • \hyphenation enter a sequence pf exceptional hyphenations.
  • \linebreak allow to break the line here.
  • \newline request a new line.
  • \newpage request a new page.
  • \nolinebreak no line break should happen here.
  • \nopagebreak no page break should happen here.
  • \pagebreak encourage page break.


vendredi 5 octobre 2012

numbering paragraphs automatically in LaTeX

In order to add paragraph numbers automatically in a LaTeX file, this is what I did.

In my Mac machine:
1) download parano.py from http://sarovar.org/frs/?group_id=35&release_id=40
2) put it in my Mac : /usr/local/texlive/2012/texmf-dist/tex/latex/base
3) sudo texhash

In my Linux machine, then the path /usr/local/texlive/2012/texmf-dist/tex/latex/base is not right, and the latex parano.sty not found !

I then tried in the linux machine:
kpsewhich -var-value TEXMFHOME

it prints the path ~/texmf.

For Linux system, either we can put the new sty files in ~/texmf/, or /usr/share/texmf. Because, when texlive searches for files, it first looks into ~/texmf, and then into /usr/local/share/texmf, and then into /usr/share/texmf. In fact it is better to put into ~/texmf than the /usr/share/texmf. The structure of ~/texmf can be organised the same as /usr/share/texmf. In this case, I created ~/texmf/tex/latex and then copied parano.sty into there.


Then I tried in Linux system:
kpsewhich parano.sty

it gives the full path where the parano.sty is put, ie., ~/texmf/tex/latex/parano.sty

--------------------------------------------------------------------------------------------------------
After the new .sty file is properly put in the systems (either Mac or Linux), now I modified my LaTeX document in order to use the parano.sty.

In the tex document, I add two lines in the beginning of file:

\usepackage{parano}
\renewcommand\theparano{\textbf{[\arabic{parano}]}}

then at the first section of document, I also put:
\section{Introduction}
\parano{}
\noindent{}

Afterwards I compile the LaTeX file, the paragraph numbers are added automatically !


mercredi 29 août 2012

Update texlive in ubuntu

I have the old version of Utuntu: karmic, and an old version of texlive 2007. I want to use the latest texlive and install in my ubuntu system.

I used the following steps:

wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
tar -xvf install-tl-unx.tar.gz
cd install-tl*
sudo ./install-tl

The above links use the generic mirror.ctan.org url which autoredirects to a CTAN mirror that should be reasonably nearby and reasonably up to date.
change PATH, I did so by editing ~/.bashrc:  

 PATH=/usr/local/texlive/2012/bin/i386-linux:$PATH

If you're re-installing after a previous attempt, be sure to completely remove your old installation. By default, this would be in these two directories (on Unix-like systems):
rm -rf /usr/local/texlive/2012
rm -rf ~/.texlive2012


After a successful installation, try simple test of latex compilation.


The default is to configure for A4 paper.  To make the default be
8.5x11 letter-size paper, you can use the ‘o’ command before installing), or run tlmgr paper letter after installation (and after setting the PATH).




mardi 15 juin 2010

tricks in latex

1) use double line spacing:

\renewcommand{\baselinestretch}{1.66}\normalsize

2) organize the figures in column:
use the tablular for organizing the figures.s
\begin{figure}
\begin{center}
\begin{tabular}{cc}
\includegraphics[width=6cm,height=14cm]{Figure1.png}
\includegraphics[width=6cm,height=14cm]{Figure2.png}
\end{tabular}
\end{center}
\caption{Two examples of DEMETER and MHR observations.}
\end{figure}

3) adding more space between the columns of text:
#define that the report is presented in two columns
\documentclass[11pt,landscape,twocolumn]{report}
#define the column distance
\addtolength{\columnsep}{5mm}

Latex enumerate

To itemize some texts in latex, there are several ways.

1) use the circle point:
\begin{itemize}
\item texts
\end{itemize}

2) for more options, use the package enumerate.

\usepackage{enumerate}
% for example
\begin{enumerate}[argument] :
% if argument is A : \item produces A. B.....
% if argument is a : \item produces a. b.
% if argument is I : \item produces I, II, IIi
% if argument is i : \item produces i, ii, iii..
% if argument is 1: \item produces 1, 2, 3
% if argument is is EX i : \item produces EX i., EX ii,
% if argument is {A}-I \item produces A-I, A-II,...
\end{enumerate}

jeudi 10 juin 2010

latex notes

Bon, je try to write a report with latex and got some errors during the compilation. I start to solve them one by one. Here are some notes.

The basic structure of the text is as follows.

\documentclass[12pt,a4paper]{report} #specify font size, paper size, doc type
\title{report title }
\author{me}
\usepackage{amsmath} #include the latex packages.
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{url}

\begin{document} # the beginning of the main document
\maketitle
\chapter{Introduction}
\section{}
\subsection{}
\end{document} # end of document

1) to use \url for presenting a web link, I need include \usepackage{url} in the beginning. It is very convenient to just write \url {www.link.com} in the text.

2) For representing degrees, use $^{\circ}$

3) insert a figure:
\begin{figure}
\begin{center}
\includegraphics[width=7cm,height=50mm]{figure.jpg}
\caption{Figure caption.}
\end{center}
\end{figure}

4) insert items
\begin{itemize}
\item{text}
\end{itemize}