Skip to content

Instantly share code, notes, and snippets.

@julien-h
Created April 28, 2018 13:38
Show Gist options
  • Save julien-h/e77bfffe25caf5fcc5cae135cb153f80 to your computer and use it in GitHub Desktop.
Save julien-h/e77bfffe25caf5fcc5cae135cb153f80 to your computer and use it in GitHub Desktop.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Math Book Template
% Features:
% - Boxed theorem, definition, etc.
% - Clever references using page number and hyperlink
% - French encoding
%
% Author: Julien HARBULOT
% Licence: MIT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[french, oneside]{book}
\usepackage{xparse} % Easier command modification
%----------------------------------------------------------------------------
% ENCODING AND FRENCH
% http://perso.mines-albi.fr/~gaborit/latex/latex-in-french.html
\usepackage[utf8]{inputenc}
\usepackage[cyr]{aeguill}
\usepackage{xspace}
\usepackage[english,francais]{babel}
\usepackage{url}
\let\urlorig\url
\renewcommand{\url}[1]{%
\begin{otherlanguage}{english}\urlorig{#1}\end{otherlanguage}%
}
%----------------------------------------------------------------------------
% Names for color (e.g. green, red)
\usepackage[svgnames]{xcolor}
%----------------------------------------------------------------------------
% MATH
% http://www.ctex.org/documents/packages/math/amsthdoc.pdf
\usepackage{amsmath, amsthm, amssymb, amsfonts}
%----------------------------------------------------------------------------
% Custom style for thm, etc.
%https://tools.ietf.org/doc/texlive-doc/latex/mdframed/mdframed.pdf
\usepackage[framemethod=tikz]{mdframed}
% Dummy counter for numbering
\newtheorem{counter}{Counter}
\theoremstyle{definition}
\newmdtheoremenv[
linecolor=blue!25,
roundcorner=5pt,
linewidth=1pt,
innertopmargin=0pt,
]{adef}[counter]{Définition}
\newmdtheoremenv[
hidealllines=true,
leftline=true,
linewidth=3pt,
innerleftmargin=10pt,
innerrightmargin=10pt,
innertopmargin=0pt,
linecolor=blue!10,
]{arem}{Remarque}
\newmdtheoremenv[
hidealllines=true,
leftline=true,
linewidth=3pt,
innerleftmargin=10pt,
innerrightmargin=10pt,
innertopmargin=0pt,
linecolor=OliveDrab!20,
]{aprop}[counter]{Proposition}
\newmdtheoremenv[
linecolor=OliveDrab!50,
roundcorner=5pt,
linewidth=1pt,
innertopmargin=0pt,
]{athm}[counter]{Théorème}
\newmdtheoremenv[
hidealllines=true,
leftline=true,
linewidth=3pt,
innerleftmargin=10pt,
innerrightmargin=10pt,
innertopmargin=0pt,
linecolor=gray!25,
]{aproof}[counter]{Preuve}
%----------------------------------------------------------------------------
% STUFF
%Smaller left and right margin
\usepackage[includeheadfoot,margin=2cm]{geometry}
%Useless
\usepackage{blindtext}
\usepackage{lipsum}
%----------------------------------------------------------------------------
% QUOTE
\let\oldquote\quote
\let\endoldquote\endquote
\RenewDocumentEnvironment{quote}{om}
{\oldquote\itshape}
{\par\nobreak\smallskip
\hfill(#2\IfValueT{#1}{~---~#1})\endoldquote
\addvspace{\bigskipamount}}
% Usage:
% \begin{quote}[source]{author} ... \end{quote}
%----------------------------------------------------------------------------
% Better ref
% Note: this include section should be the last
% Page number in reference
\usepackage{varioref}
% Hyperlink to target in pdf
\usepackage[colorlinks=true, backref=true, linkcolor=blue]{hyperref} %hyperlink (click on ref to jump)
% Auto name the target. e.g: (eq. 1)
% http://tug.ctan.org/tex-archive//macros/latex/contrib/cleveref/cleveref.pdf
\usepackage[nameinlink]{cleveref} %name the target (eq. 1)
% Define target names
\crefname{adef}{Def}{Defs}
\crefname{aprop}{Prop}{Propositions}
\crefname{athm}{Thm}{Théorèmes}
\crefname{aproof}{Preuve}{Preuves}
\crefname{arem}{Rem}{Remarques}
% Redefine the command name, in case I use other packages later
\let\aref\Vref
%----------------------------------------------------------------------------
\begin{document}
\frontmatter
\title{Titre du document}
\author{Julien Harbulot}
\date{Avril 2017}
\maketitle
%----------------------------------------------------------------------------
\mainmatter
\chapter{Premier chapitre}
\lipsum[4]
\begin{quote}[Le livre de la vérité]{Moi}
Ceci est une citation
\end{quote}
\lipsum[4]
\begin{adef}
\lipsum[4]
\end{adef}
\begin{arem}\label{prop1}
\lipsum[4]
\end{arem}
\begin{aprop}
\lipsum[4]
\end{aprop}
\begin{arem}\label{prop2}
\lipsum[4]
\end{arem}
\begin{athm}
\lipsum[4]
\end{athm}
\begin{aproof}
\lipsum[4]
\end{aproof}
\begin{arem}
\lipsum[4]
\end{arem}
%----------------------------------------------------------------------------
%\appendix
%\chapter{First Appendix}
%\backmatter
%\chapter{Last note}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment