Quickies » LaTeX
LaTeX
Catégories
Titres
Contenu
  1. Add an additional directory path for graphics for \includegraphics
    \graphicspath{{./images/}}
    

    [Retour en haut]
  2. Algorithmes

    Algorithmes

    Avec les paquetages algorithmic et algorithm.

    %%% francisation des algorithmes
    \renewcommand{\algorithmicrequire} {\textbf{\textsc{Entrées:}}}
    \renewcommand{\algorithmicensure}  {\textbf{\textsc{Sorties:}}}
    \renewcommand{\algorithmicwhile}   {\textbf{tantque}}
    \renewcommand{\algorithmicdo}      {\textbf{faire}}
    \renewcommand{\algorithmicendwhile}{\textbf{fin tantque}}
    \renewcommand{\algorithmicend}     {\textbf{fin}}
    \renewcommand{\algorithmicif}      {\textbf{si}}
    \renewcommand{\algorithmicendif}   {\textbf{finsi}}
    \renewcommand{\algorithmicelse}    {\textbf{sinon}}
    \renewcommand{\algorithmicthen}    {\textbf{alors}}
    \renewcommand{\algorithmicfor}     {\textbf{pour}}
    \renewcommand{\algorithmicforall}  {\textbf{pour tout}}
    \renewcommand{\algorithmicdo}      {\textbf{faire}}
    \renewcommand{\algorithmicendfor}  {\textbf{fin pour}}
    \renewcommand{\algorithmicloop}    {\textbf{boucler}}
    \renewcommand{\algorithmicendloop} {\textbf{fin boucle}}
    \renewcommand{\algorithmicrepeat}  {\textbf{répéter}}
    \renewcommand{\algorithmicuntil}   {\textbf{jusqu'à}}
    
    \floatname{algorithm}{Algorithme}
    
    \let\mylistof\listof
    \renewcommand\listof[2]{\mylistof{algorithm}{Liste des algorithmes}}
    
    % pour palier au problème de niveau des algos
    \makeatletter
    \providecommand*{\toclevel@algorithm}{0}
    \makeatother
    
    %\listofalgorithms % pour lister les algos (après la toc)
    

    ...

    \begin{algorithm}
    \caption{Algorithme d'Euclide}
    \begin{algorithmic}
    %%-----------------------------------------------
    \REQUIRE $a, b \in {\mathbb N}$         % demande le paq. amssymb
    \ENSURE le pgcd de $a$ et $b$
    
    \STATE $x \leftarrow \textrm{max}(a,b)$
    \STATE $y \leftarrow \textrm{min}(a,b)$
    
    \WHILE {$y \neq 0$}
       \STATE $x \leftarrow y$
       \STATE $y \leftarrow x \mod y$       % demande le paq. amsmath
    \ENDWHILE
    
    \STATE Retourner $x$.
    %%-----------------------------------------------
    \end{algorithmic}
    \end{algorithm}
    

    [Retour en haut]
  3. Alignements

    Alignements

    \begin{flushleft}
    Voie lactée ô soeur lumineuse \\
    Des blancs ruisseaux de Chanaan
    \end{flushleft}
    
    \begin{flushright}
    Et des corps blancs des amoureuses \\
    Nageurs morts suivrons-nous d'ahan
    \end{flushright}
    
    \begin{center}
    Ton cours vers d'autres nébuleuses
    \end{center}
    

    [Retour en haut]
  4. Automate

    Automate fini déterministe.

    Automate

    Avec le paquetage vaucanson-g.

    \MediumPicture\VCDraw{% 
    \begin{VCPicture}{(0,-4)(4,4)}
    % states
    \State[1]{(0,0)}{1}
    \State[2]{(8,0)}{2}
    \FinalState[3]{(4,0)}{3}
    \State[4]{(0,-4)}{4}
    \FinalState[5]{(4,-4)}{5}
    % initial--final
    \Initial{1}
    %\Final{10}
    % transitions 
    \EdgeL{1}{3}{a}
    \EdgeL{1}{4}{b}
    \EdgeL{1}{5}{c}
    \ArcL{2}{3}{a}
    \EdgeL{2}{5}{c}
    \LoopN{3}{a}
    \ArcL{3}{2}{b}
    \ArcL{3}{5}{c}
    \ArcL{4}{5}{c}
    \ArcL{5}{3}{a}
    \ArcL{5}{4}{b}
    \LoopS{5}{c}
    \end{VCPicture}
    }
    

    [Retour en haut]
  5. Calligraphie

    Calligraphie enfantine

    Avec la police French Cursive, les paquetages color et frcursive.

    Police créée par Emmanuel Beffara.

    \renewcommand{\seyesDefault}{\color{blue}}
    

    ...

    \begin{document}
    

    ...

    \begin{cursive}
      Vive l'école maternelle !
    
      \textbf{Gras}
      \textit{Italique} 
      \textcal{Calligraphie} % \calserie Calligraphie
    \end{cursive}
    
    \begin{quote}
      \cursive
      \seyes{Lignes normales.}
    \end{quote}
    
    \begin{quote}
      \cursive\acadshape
      \seyes[\color{red}]{Lignes comme au tableau.}
    \end{quote}
    

    [Retour en haut]
  6. Date et heure

    Date et heure

    Avec le paquetage scrtime.

    Nous sommes le \today, il est \thistime.
    

    Sans paquetage particulier.

    % ----------------------------------------------------------------------
    % TIME OF DAY - Nelson Beebe - http://www.math.utah.edu/~beebe/
    \newcount\hh
    \newcount\mm
    \mm=\time
    \hh=\time
    \divide\hh by 60
    \divide\mm by 60
    \multiply\mm by 60
    \mm=-\mm
    \advance\mm by \time
    \def\hhmm{\number\hh:\ifnum\mm<10{}0\fi\number\mm}
    % ----------------------------------------------------------------------
    

    ...

    Nous sommes le \today, il est \hhmm.
    

    [Retour en haut]
  7. Écrire les siècles

    Siècles

    Une manière simple et élégante d'écrire les siècles, proposée par A. Chambert-Loir sur fr.comp.text.tex :

    Avec la macro code128.

    \def\siecle#1{\textsc{\romannumeral #1}\textsuperscript{e}~siècle}
    

    ...

    Depuis le \siecle{19}, tout va mal !
    

    [Retour en haut]
  8. Exemple

    Exemple

    Avec le paquetage example.

    \begin{example}
    $$
    \sum_{n=1}^{10} \cdot
    \int_a^b e^{x} ~ dx
    $$
    \end{example}
    

    [Retour en haut]
  9. Figures côte-à-côte

    Figures côte-à-côte

    Avec le paquetage graphicx.

    \begin{figure}
    \begin{minipage}[t]{.4\linewidth}
        \begin{center}
           \includegraphics[scale=0.5]{images/nb_abo.ps}
           \caption{nombre d'abonnements au téléphone}
           \label{nbabo}
        \end{center}
    \end{minipage}
    \hfill
    \begin{minipage}[t]{.4\linewidth}
        \begin{center}
           \includegraphics[scale=0.5]{images/croiss_nb_abo.ps}
           \caption{croissance du nombre d'abonnements au téléphone}
           \label{croissnbabo}
        \end{center}
    \end{minipage}
    \end{figure}
    

    [Retour en haut]
  10. Fractions

    Fractions

    (en mode mathématique)

    % http://www.ctan.org/tex-archive/macros/eplain/
    \def\fract#1/#2{\leavevmode
       \kern.1em \raise .5ex \hbox{\the\scriptfont0 #1}%
       \kern-.1em $/$%
       \kern-.15em \lower .25ex \hbox{\the\scriptfont0 #2}%
    }% 
    ...
    9\frac{1}{2}
    ...
    9\fract 1/2
    

    [Retour en haut]
  11. Interlignes

    Avec le paquetage setspace.

    \singlespace
    \onehalfspace
    \doublespace
    

    [Retour en haut]
  12. Listings package language definition for Objective-C 2.0

    Listings for Objective-C 2.0

    \usepackage{color}
    \usepackage{listings}
    
    \definecolor{pink}  {rgb}{0.67, 0.05, 0.57} % keywords
    \definecolor{red}   {rgb}{0.87, 0.20, 0.00} % strings
    \definecolor{green} {rgb}{0.00, 0.47, 0.00} % comments
    \definecolor{violet}{rgb}{0.41, 0.12, 0.61} % classes
    \definecolor{blue}  {rgb}{0.21, 0.00, 0.44} % functions
    \definecolor{brown} {rgb}{0.39, 0.22, 0.13} % brown
    
    \lstdefinelanguage{Objective-C 2.0}[Objective]{C} {
        morekeywords={id, Class, SEL, IMP, BOOL, nil, Nil, NO, YES,
                      oneway, in, out, inout, bycopy, byref,
                      self, super, _cmd,
                      @required, @optional,
                      @try, @throw, @catch, @finally,
                      @synchronized, @property, @snythesize, @dynamic},
        moredelim=[s][color{red}]{@"}{"},
        moredelim=[s][color{red}]{<}{>}
    }
    
    \lstdefinestyle{Xcode} {
        language        = Objective-C 2.0,
        basicstyle      = footnotesizettfamily,
        identifierstyle = color{black},
        commentstyle    = color{green},
        keywordstyle    = color{pink},
        stringstyle     = color{red},
        directivestyle  = color{brown},
        extendedchars   = true,
        tabsize         = 4,
        showspaces      = false,
        showstringspaces = false,
        breakautoindent = true,
        flexiblecolumns = true,
        keepspaces      = true,
        stepnumber      = 0,
        xleftmargin     = 0pt}
    
    \lstset{
        style = Xcode,
        caption=lstname,
        breaklines=false,
        frame=single
    }
    

    Use it like this:

    \begin{lstlisting}[name=Sample code, label=SampleCode]
    NSLog(@"hello");
    \end{lstlisting}
    

    List the listings:

    \lstlistoflistings
    

    [Retour en haut]
  13. Matrices

    Matrices

    Avec le paquetage amsmath, et en mode mathématique.

    \begin{matrix} 
    a & b \\
    c & d 
    \end{matrix}
    \quad
    \begin{pmatrix} 
    a & b \\
    c & d 
    \end{pmatrix}
    \quad
    \begin{bmatrix} 
    a & b \\
    c & d 
    \end{bmatrix}
    \quad
    \begin{vmatrix} 
    a & b \\
    c & d 
    \end{vmatrix}
    \quad
    \begin{Vmatrix} 
    a & b \\
    c & d 
    \end{Vmatrix}
    

    [Retour en haut]
  14. Notes dans la marge

    Notes dans la marge

    \marginpar{Ben tiens !}
    

    [Retour en haut]
  15. Opérateur modulo

    Opérateur modulo

    On écrit $a\equiv b\pmod{c}$, \\
    mais aussi $a = b \bmod c$.
    

    [Retour en haut]
  16. PSTricks

    Le Indian TeX Users Group propose une excellente introduction à PSTricks sous la forme de magnifiques fichiers PDF plein l'exemples et d'explications très bien choisis.

    Ça se télécharge sur Sarovar, le SourceForge du pays de Gandhi.


    [Retour en haut]
  17. Section non numérotée

    Section non numérotée

    Pour qu'une section (ou une sous-section, etc.) ne soit pas numérotée, il faut le signaler par une étoile.

    \section*{Introduction}
    

    Pour qu'elle apparaisse quand-même dans la table des matières, on peut ajouter la ligne suivante :

    \addcontentsline{toc}{section}{Introduction}
    

    [Retour en haut]
  18. Symbole Euro
    \usepackage{eurosym}
    
    \euro
    

    [Retour en haut]
  19. Texte barré

    Texte barré

    Avec le paquetage ulem.

    \sout{texte barré}
    

    Avec le paquetage soul.

    \st{texte barré}
    

    [Retour en haut]
  20. Texte en couleur

    Texte en couleur

    Avec le paquetage color.

    \definecolor{orange}{rgb}{1.0, 0.5, 0.0}
    \definecolor{monbleu}{rgb}{0.25, 0.25, 0.75}
    

    ...

    \paragraph{}Je peux écrire en {\color{red}rouge}, en {\color{green}vert} et en {\color{blue}bleu}. \\
    Je peux aussi écrire en {\color{orange}orange} ou avec {\color{monbleu}mon bleu}. \\
    Ce n'est pas toujours \colorbox{monbleu}{\color{orange}très beau}.
    

    [Retour en haut]
  21. Texte sur plusieurs colonnes

    Texte sur plusieurs colonnes

    Avec le paquetage multicol.

    \begin{multicols}{3}
    

    ...

    \end{multicols}
    

    [Retour en haut]
  22. Texte surligné

    Texte surligné

    Avec les paquetages soul et color.

    \definecolor{bleuclair}{rgb}{0.7, 0.7, 1.0}
    \definecolor{rosepale}{rgb}{1.0, 0.7, 1.0}
    
    \newcommand{\hlrose}[1]{\sethlcolor{rosepale}\hl{#1}}
    
    \begin{document}
    
    On peut \hl{surligner un texte avec la couleur par défaut}.
    
    On peut choisir \hlrose{une autre couleur}.
    
    \sethlcolor{bleuclair}
    
    On peut aussi \hl{changer} la \hl{couleur} par \hl{défaut}.
    

    [Retour en haut]
  23. Typographie française

    Typographie française

    Avec les paquetage babel et l'option francais.

    \begin{tabular}{llll}
    M\up{me}, M\up{mes}    & Jean-Michel     & 1\ier\ 1\iere\ 1\ieres  & \og guillemets \fg          \\
    M\up{lle}, M\up{lles}  & pp.~12--15      & 2\ieme\ 2\iemes         & \nombre{1234,56}            \\
    M. \bsc{Dupont},       & --- en fait --- & \No 1, \no 2            & {\OE}uf, {\oe}ufs, \AE, \ae \\
    M\up{e}, M\up{gr}, MM. & $-1$ degrés     & 13\degres, 23~\degres C & À l'État.
    \end{tabular}
    

    Liens

    perso.wanadoo.fr résumé des règles typographiques de base (générales et scientifiques)
    listetypo.free.fr Orthotypographie [pdf], ouvrage posthume et inachevé, sur la page de Jean-Pierre Lacroux.


    [Retour en haut]
  24. URLs

    URLs

    Avec le paquetage url.

    \newcommand\email{\begingroup \urlstyle{rm}\Url}
    \newcommand\web{\begingroup \urlstyle{tt}\Url}
    

    ...

    \email{nicolas@seriot.ch}
    

    ...

    \web{http://seriot.ch}
    

    [Retour en haut]
Tout afficher - Imprimer - Recherche avancée - RSS
© 2010 Nicolas Seriot