tricks

this is obsolete doc -- see http://doc.nethence.com/ instead

LaTeX tips & tricks 

 

Base preamble 

If your GUI is LyX you might want to start with this to disable the automatic date, 

\date{}

 

Then it's good to enable Babel for spell checking and hyphenation. Csquotes is also recommended for use with Biblatex. The default language is the last one mentioned, here french. 

\usepackage[english,ngerman,frenchb]{babel}
\usepackage{csquotes}

 

Change the text for the Bibliography heading according to your taste and language e.g., 

\renewcommand\refname{Enquête et bibliographie

 

Biblatex tricks 

Enable Biblatex with the traditional style (full citation in body or footnote and some limited loc/op cit capabilities), 

\usepackage[style=verbose-trad1,backend=biber,
autolang=hyphen,language=auto,

sorting=nyt

maxbibnames=99,
citepages=separate,
]{biblatex}

Note. stick with biber if you are using LyX and you've set it up in Tools > Options. change to bibtex8 if you are using TexWorks otherwise you'll end up with an error (as far Miktex 2.9 is concerned). 

Note. language=auto to also handle idem entries with babel. 

Note. sorting=nyt only works (and is the default) with biber processor, not with bibtex8. 

Note. maxbibnames to print all authors, disable short name list in the citation. 

Note. citepages=seperate as with verbose-* styles, this allows to show both: total pages and the `esp.' page. 

 

Don't forget to load your bibliography, better soon than never, 

\addbibresource{test.bib}

 

Since Lyx 2.1 and a local layout script I could work around that trick, but I prefer to keep using it, 

\let\cite=\footcite

 

Put the first name first, 

\DeclareNameAlias{sortname}{first-last}

 

Change the delimiter from '. ' to ', ', 

\renewcommand*{\newunitpunct}{\addcomma\space}

 

Print Ibidem in italics, 

\renewcommand*{\mkibid}{\emph}

 

Suppress 'in: ' for journals and co., 

\renewbibmacro{in:}{}

 

 

Define a macro \mkbiblege analogous to \mkbibparens to wrap text in < and >, 

\makeatletter
\newrobustcmd{\mkbiblege}[1]{%
  \begingroup
  \blx@blxinit
  \blx@setsfcodes
  <#1>
  \endgroup}
\makeatother

Ref. http://tex.stackexchange.com/questions/151110/how-to-fix-the-url-and-doi-font-say-make-it-smaller 

 

Adapt the bibliography strings according to your taste and language, 

\DefineBibliographyStrings{french}{

urlseen = {consulté le}, 

  url = {en ligne},
idem = {Idem},
idemsm = {Idem},
idemsf = {Eadem},
idemsn = {Idem},
idempm = {Eidem},
idempf = {Eaedem},
idempn = {Eadem},
idempp = {Eidem},
ibidem = {Ibid\adddot},
opcit = {op\adddotspace cit\adddot},
loccit = {loc\adddotspace cit\adddot},
}
\DeclareFieldFormat{urldate}{\addcomma\space\bibstring{urlseen}\space#1}
\DeclareFieldFormat{url}{\bibstring{url}\space\mkbiblege{\url{#1}}}

 

Remove parenthesis made by footcite in a footnote, 

\makeatletter
\renewrobustcmd{\blx@mkbibfootnote}[2]{%
  \iftoggle{blx@footnote}
    {\blx@warning{Nested notes}%
     \addspace{#2}}% this was: \addspace\mkbibparens{#2}}
    {\unspace
     \ifnum\blx@notetype=\tw@
       \expandafter\@firstoftwo
     \else
       \expandafter\@secondoftwo
     \fi
       {\csuse{blx@theendnote#1}{\protecting{\blxmkbibnote{end}{#2}}}}
       {\csuse{footnote#1}{\protecting{\blxmkbibnote{foot}{#2}}}}}}
\makeatother

Ref. http://tex.stackexchange.com/questions/150959/biblatex-hack-how-to-remove-parenthesis-made-by-footcite-in-a-footnote 

 

Other tricks 

Use a smaller and lighter font size for URLs and DOIs footnotes versus body, add this to the preamble, 

\usepackage{xcolor}
\definecolor{gris}{gray}{0.25}
\renewcommand{\UrlFont}{\iffootnote{\color{gris}\scriptsize\rm}{\color{gris}\small\rm}}

Note. An alternative would be to use some of those or to use the `resize' package, 

%\renewcommand{\UrlFont}{\iffootnote{\scriptsize\rm}{\small\rm}}
%\urlstyle{same}

 

To remove the text on figures, add this to the preamble, 

\usepackage[labelformat=empty]{caption}

 

Advanced footnote layout 

You can further configure the footnote layout with the footmisc package e.g., 

\usepackage[perpage,para,bottom,multiple]{footmisc}

Note. It is tricky to make it work with babel so here it goes all in all, 

\usepackage[english,ngerman,frenchb]{babel}
\usepackage{csquotes}
\frenchbsetup{FrenchFootnotes=false}
\usepackage[perpage,para,bottom,multiple]{footmisc}

Note. For having raggedright footnotes you might add, 

\renewcommand{\footnotelayout}{\raggedright}

Note. And to prevent a footnote to spread on several pages you might want to force it on the same page, 

\interfootnotelinepenalty=10000

Note. Finally if you need to enable the hyperref package but want to exclude the footnotes, 

%\usepackage[hyperfootnotes=false]{hyperref}

 

In the previous example, english is activated by default although it may not be an english document. It is needed to get the footnote right, and you need to switch to french manually. Start the document with, 

(ERT) \selectlanguage{frenchb}

 

An alternative to the to handle multiple footnotes would be, 

\let\oldFootnote\footnote
\newcommand\nextToken\relax
\renewcommand\footnote[1]{%
    \oldFootnote{#1}\futurelet\nextToken\isFootnote}
\newcommand\isFootnote{%
    \ifx\footnote\nextToken\textsuperscript{,}\fi}

 

Refs. 

Incompatibility between footmisc-option multiple and hyperref: http://tex.stackexchange.com/questions/40072/incompatibility-between-footmisc-option-multiple-and-hyperref 

 

MWE tricks 

To show the text body AND the footnote next to each other, push the text to the bottom with, 

\null\vfill

Refs. 

\vspace after \vfill ignored: http://tex.stackexchange.com/questions/82419/vspace-after-vfill-ignored 

Why are URLs typeset with monospace fonts by default?: http://tex.stackexchange.com/questions/53962/why-are-urls-typeset-with-monospace-fonts-by-default 

What is \null and when do we need to use it?: http://tex.stackexchange.com/questions/24919/what-is-null-and-when-do-we-need-to-use-it 

 

To check margins and text layout you could also add this in the preamble, 

\usepackage{lipsum}

and this in the body, 

\lipsum[1]

Note. optional argument '1' here for just one paragraph, otherwise the default occupies more than one page. 

 

Bibtex / Natbib tricks 

Get rid of the numbering of the 'plain' or 'plainnat' Bibtex styles, 

\makeatletter
\renewcommand\@biblabel[1]{}
\makeatother

 

bibentry package 

To configure Natbib with the bibentry package, configure Natbib as usual and add this preamble to the document, 

\usepackage{bibentry}
\nobibliography*

you should now be able to insert complete references by doing, 

  (ERT) \bibentry{clé

 

Bibtex / Jurabib tricks 

Choose a Jurabib style among: jox, jurabib, juraeco or jurunsrt. 

 

Add this preamble e.g., 

\jurabibsetup{
authorformat={allreversed,and,reducedibidem},
%Replaces recurring authors name(s) by a dash
bibformat=ibidem,
%removes bold author name
%biblikecite,
citefull=first,
commabeforerest,
dotafter=bibentry,
ibidem=strictdoublepage,
idem=strictdoublepage,
titleformat={commasep,italic},
super,
}

\renewcommand{\bibtfont}{\textit} 

\renewcommand{\bibansep}{, }
\renewcommand{\bibatsep}{, }
\renewcommand{\bibbdsep}{, }

Note. The 'super' option allows you to use complete references in footnotes with just \cite (default button in LyX). 

Note. The 'lookat' option which points to another note on a previous page conflicts with some documents types. And I prefer the classical ibid style anyway. 

 

Only problem with Jurabib (apart from the fact that it isn't maintained anymore): it doesn't handle internationalized bibliographies. 

 

Bibtex / Babelbib tricks 

(FR) Copiez 'C:\Program Files\MiKTeX 2.9\bibtex\bst\babamspl.bst' sur le bureau puis renommez le en 'babamspl-custom.bst' afin d'en retirer tous les appels à la fonction 'format.language' ainsi que, facultativement, la fonction elle-même. Cela désactive l'indication de la langue de l'ouvrage à la fin de chaque entrée bibliographique (elle est affichée si différente de la langue principale du document). 

 

You can also use the Bibtex Babelbib style for internationalized bibliography, 

\usepackage[english,ngerman,francais]{babel}
\usepackage[varlanguage]{babelbib}
\setbtxfallbacklanguage{francais}

 

In the bib file, 

  Language                 = {french},

or 

  Language                 = {english},

Note. in e.g. the title entry, do not place a space before colons (or only in the languages that need one, eventually), those will be added if non-english entry. 

 

You will notice that hyphenation and colons are placed adequately depending on the bib entry language parameter. 

 

Ref. Multilingual bibliographies: The babelbib package: http://get-software.net/biblio/bibtex/contrib/babelbib/babelbib.pdf 

 

Additional notes 

General 

The first paragraph's identation depends on the default language, (enabled for french, disabled for english), so it is automatic and you shouldn't use it. If you really want to force that identation when it doesn't happen (e.g. english language), 

\usepackage{indentfirst}

 

(FR) Nota. Si vous souhaitez faire apparaître des éléments indépendants dans la table des matières (et non pas si vous souhaitez simplement retirer les numéros aux chapitres, auquel cas je vous invite simplement à suivre la procédure décrite plus haut au sujet de la configuration de la numérotation), 

Ctrl-L

  \addcontentsline{toc}{chapter}{\protect\numberline{}Introduction générale} 

Refs. 

http://patatos.over-blog.com/article-comment-faire-apparaitre-les-chapitres-non-numerotes-dans-la-table-des-matieres-avec-lyx-111573508.html 

http://tex.stackexchange.com/questions/11668/adding-unnumbered-sections-to-toc 

 

Biblatex 

For verbose-* styles that do note-style (page) referencing in the footnotes (I do not use those), make sure it is enabled in the biblatex options, 

[...,pageref,pagetracker=true,]

 

Global references 

Index of /LaTeX/cours: http://blaise.info.meteo.free.fr/LaTeX/cours/ 

LaTeX: http://blog.oak-tree.us/index.php/writing/latex 

Getting to Grips with LaTeX: http://www.andy-roberts.net/writing/latex/formatting 

\pagebreak vs \newpage: http://tex.stackexchange.com/questions/736/pagebreak-vs-newpage 

LaTeX/Paragraph Formatting: http://en.wikibooks.org/wiki/LaTeX/Paragraph_Formatting 

 

References about document types 

Why should I *not* use the KOMA-Script classes?: http://tex.stackexchange.com/questions/73141/why-should-i-not-use-the-koma-script-classes 

 

References about footnotes 

LaTeX Footnotes: http://www.personal.ceu.hu/tex/footnote.htm 

LaTeX footnotes: http://help-csli.stanford.edu/tex/latex-footnotes.shtml 

LaTeX/Footnotes and Margin Notes: http://en.wikibooks.org/wiki/LaTeX/Footnotes_and_Margin_Notes 

Multiple footnotes at one point: http://tex.stackexchange.com/questions/28465/multiple-footnotes-at-one-point 

comma delineation of consecutive endnotes: http://tex.stackexchange.com/questions/54050/comma-delineation-of-consecutive-endnotes 

Footnotes/Endnotes: http://www.compsoc.man.ac.uk/~moz/www-user/help/footnotes.php 

3.2. Footnotes, endnotes, and marginals: http://my.safaribooksonline.com/book/graphic-design/0201362996/basic-formatting-tools/ch03lev1sec2 

footmisc: http://www.learningace.com/doc/5994982/5630247d4a1d95b346b3d00dd1c8c8ce/footmisc 

Change line spacing for footnote text only: http://tex.stackexchange.com/questions/32280/change-line-spacing-for-footnote-text-only 

 

References about packages 

hyphenat – Disable/enable hypenation: http://ctan.org/pkg/hyphenat 

 

References about endnotes 

EndNotes: http://wiki.lyx.org/Tips/EndNotes 

Customize endnotes: http://tex.stackexchange.com/questions/67794/customize-endnotes