latex-homework/commun/commun.sty

561 lines
13 KiB
Plaintext
Raw Normal View History

2016-03-22 11:49:55 +00:00
%%%
%%%
%%% Extensions : commun.sty
%%% Version : 1.0
%%% Date : 03/05/15
%%%
%%% Version : 2.0
%%% Date : 11/08/16
%%% Mods : Change some packages call to be compatible with LuaLaTeX
%%%
2016-03-22 11:49:55 +00:00
%%% Auteur : Jeff LANCE
%%%
%%%
\NeedsTeXFormat{LaTeX2e}
2017-03-19 15:23:56 +00:00
\ProvidesPackage{commun}[2015/05/03 Ensembles d'environnements et de fonctions
utilisables partout, v2.0]
2016-03-22 11:49:55 +00:00
2018-08-20 13:59:45 +00:00
%
%
% PACKAGES
%
%
2017-03-19 17:05:13 +00:00
2018-08-20 13:59:45 +00:00
% development
\RequirePackage{xifthen}
\RequirePackage{ifmtarg}
\RequirePackage{ifpdf}
\RequirePackage{xstring}
\RequirePackage{multido}
\RequirePackage{xparse}
2019-11-02 09:50:53 +00:00
\RequirePackage{etoolbox, xpatch}
\RequirePackage{ifluatex}
2016-09-27 09:55:38 +00:00
\RequirePackage{import}
2018-10-04 20:32:37 +00:00
\RequirePackage{lipsum}
2020-08-20 09:42:10 +00:00
\RequirePackage{subfiles}
2018-08-20 13:59:45 +00:00
% language
\ifluatex
\RequirePackage{polyglossia} % => babel
\setdefaultlanguage{french} % => inputenc
\RequirePackage{luatextra} % charge fontspec => fontenc
2018-02-16 14:56:32 +00:00
% \defaultfontfeatures{Ligatures=TeX}
\else
2017-05-12 19:24:21 +00:00
\RequirePackage[francais]{babel} % => polyglossia
\RequirePackage[utf8]{inputenc} % => fontspec
\RequirePackage[T1]{fontenc} % => fontspec
% \RequirePackage[babel=true,kerning=true]{microtype}
\fi
2018-08-20 13:59:45 +00:00
% fonts
2016-03-22 11:49:55 +00:00
\RequirePackage{libertine}
2016-08-12 09:48:12 +00:00
\RequirePackage{pifont}
\RequirePackage{fontawesome}
\RequirePackage[right]{eurosym}
2018-09-11 05:52:15 +00:00
\RequirePackage{frcursive}
2018-11-04 09:15:58 +00:00
\RequirePackage{emerald}
2016-08-12 09:48:12 +00:00
2018-08-20 13:59:45 +00:00
% color and graphics
2016-08-13 10:49:10 +00:00
\ifluatex
\RequirePackage{luacolor}
\fi
% \RequirePackage{tipfr}
2018-09-11 05:52:15 +00:00
%\RequirePackage[table,xcdraw]{xcolor} % there's a bug when used with some mdframed content
\RequirePackage[]{xcolor}
\RequirePackage[framemethod=tikz]{mdframed}
2016-06-12 16:12:47 +00:00
\RequirePackage{graphicx}
2017-03-02 00:19:30 +00:00
\RequirePackage{transparent}
2018-09-11 05:52:15 +00:00
\RequirePackage{fancybox}
\RequirePackage[tikz]{bclogo}
2016-03-22 11:49:55 +00:00
% maths
2019-11-02 09:50:53 +00:00
\RequirePackage{amsmath, amsthm, amsfonts, amssymb}
2016-03-22 11:49:55 +00:00
\RequirePackage{tkz-euclide}
2021-02-18 22:08:40 +00:00
\usetikzlibrary{arrows, calc, positioning, shapes.geometric, shadows, snakes, tikzmark}
2016-03-22 11:49:55 +00:00
\RequirePackage{calc}
2018-09-11 05:52:15 +00:00
% \RequirePackage{pgffor,pgfmath} % loaded by tikz
2016-03-22 11:49:55 +00:00
\RequirePackage{pgfplots}
2018-09-11 05:52:15 +00:00
\pgfplotsset{compat=1.16}
2020-09-03 17:47:37 +00:00
\RequirePackage[load-configurations = abbreviations]{siunitx}
2016-03-22 11:49:55 +00:00
\RequirePackage{asymptote}
2016-05-28 21:16:55 +00:00
\RequirePackage{mathrsfs}
2018-09-03 14:08:40 +00:00
\RequirePackage{xlop}
2016-03-22 11:49:55 +00:00
2018-09-11 05:52:15 +00:00
% tableaux de signe
%\RequirePackage{tabvar} % replaced by pdftabvar from pdfadd
\RequirePackage{fp}
\ifluatex
\RequirePackage[luatex]{pict2e}
\fi
2018-09-11 05:52:15 +00:00
\RequirePackage{picture}
\RequirePackage{color}
\input pdftabvar
%
2018-08-20 13:59:45 +00:00
% tables
2016-03-22 11:49:55 +00:00
\RequirePackage{array}
\RequirePackage{tabularx}
2019-11-02 09:50:53 +00:00
\RequirePackage{makecell}
2016-05-11 12:58:49 +00:00
\RequirePackage{multicol}
2018-12-08 19:25:10 +00:00
\RequirePackage{multirow}
2017-02-17 17:27:18 +00:00
\RequirePackage{boldline}
\RequirePackage{colortbl}
2018-08-20 13:59:45 +00:00
% layout
\RequirePackage{varwidth}
2016-12-14 17:37:20 +00:00
\RequirePackage{adjustbox}
2018-09-11 05:52:15 +00:00
\RequirePackage{lscape}
2018-12-08 19:25:10 +00:00
\RequirePackage{multicol}
2017-05-12 19:24:21 +00:00
2018-08-20 13:59:45 +00:00
% text
2018-09-11 05:52:15 +00:00
\RequirePackage[dash]{dashundergaps}
2018-08-19 17:58:59 +00:00
\RequirePackage{comment}
2018-09-03 14:08:40 +00:00
\RequirePackage{caption}
2018-10-04 20:32:37 +00:00
\RequirePackage[outputdir=./build]{minted}
\RequirePackage{inconsolata}
2018-10-16 21:08:37 +00:00
\RequirePackage{tasks}
2019-01-13 09:26:52 +00:00
\RequirePackage{dashrule}
2020-04-18 14:18:29 +00:00
\RequirePackage{qrcode}
2020-09-23 18:39:21 +00:00
\RequirePackage{verse}
\RequirePackage{nicefrac}
2020-12-11 12:29:50 +00:00
\RequirePackage{blindtext}
2018-11-04 09:15:58 +00:00
%--
2018-08-20 13:59:45 +00:00
2016-03-22 11:49:55 +00:00
2017-02-17 15:27:44 +00:00
\makeatletter
2016-03-22 11:49:55 +00:00
2018-08-20 13:59:45 +00:00
%
%
% SETTINGS
%
%
2016-03-22 11:49:55 +00:00
2018-10-04 20:32:37 +00:00
% Set the default monospaced font
2021-05-27 10:36:36 +00:00
\ifluatex
\setmonofont[StylisticSet=3]{Inconsolatazi4}
\fi
2018-12-08 19:25:10 +00:00
% tasks
\settasks{
label-format = {\bfseries}
}
2019-11-12 16:47:48 +00:00
% siunitx
\sisetup{
2020-09-03 17:47:37 +00:00
locale=FR,
2019-11-12 16:47:48 +00:00
output-decimal-marker={,},
inter-unit-product={\ensuremath{ { } \cdot { } }},
}
2020-04-18 14:18:29 +00:00
% caption
\captionsetup{font=small}
\captionsetup[figure]{labelfont=bf, textfont=it, name=Figure}
\captionsetup[table]{labelfont=bf, textfont=it, name=Tableau}
2018-11-04 09:15:58 +00:00
%--
2018-10-04 20:32:37 +00:00
2018-08-19 17:58:59 +00:00
2018-08-20 13:59:45 +00:00
%
%
% MACROS
%
%
2018-08-19 17:58:59 +00:00
2021-02-18 22:08:40 +00:00
%
% Tikz
%
\tikzstyle{arrow} = [thick,->,>=stealth]
2018-08-20 13:59:45 +00:00
% Tableau
% Alignment commands of the content in the column with a defined width.
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
2018-09-25 04:42:35 +00:00
\newcolumntype{M}[1]{>{\centering}m{#1}}
2016-03-22 11:49:55 +00:00
%% lh{largeur} : gauche - haut
%\newcolumntype{lh}[1]{>{\raggedright}p{#1}}
%% ch{largeur} : centre - haut
%\newcolumntype{ch}[1]{>{\centering\arraybackslash}p{#1}}
%% rh{largeur} : droite - haut
%\newcolumntype{rh}[1]{>{\raggedleft}p{#1}}
%% lc{largeur} : gauche - centre
%\newcolumntype{lc}[1]{>{\raggedright}m{#1}}
%% cc{largeur} : centre - centre
% \newcolumntype{M}[1]{ >{\centering\arraybackslash} m{#1} }
2016-03-22 11:49:55 +00:00
%% rc{largeur} : droite - centre
%\newcolumntype{rc}[1]{>{\raggedleft}m{#1}}
%% lb{largeur} : gauche - bas
%\newcolumntype{lb}[1]{>{\raggedright}b{#1}}
%% cb{largeur} : centre - bas
%\newcolumntype{cb}[1]{>{\centering}b{#1}}
%% rb{largeur} : droite - bas
%\newcolumntype{rb}[1]{>{\raggedleft}b{#1}}
2018-08-20 13:59:45 +00:00
% Item in a tab.
\newcommand{\tabitem}{~~\llap{\textbullet}~~}
2020-12-11 12:29:50 +00:00
% \firsthline with \cline capabilities
\newcommand{\firstcline}[1]{%
\multicolumn1c{%
\global\backup@length\ht\@arstrutbox
\global\advance\backup@length\dp\@arstrutbox
\global\advance\backup@length\arrayrulewidth
\raise\extratabsurround\copy\@arstrutbox
}\\[-\backup@length]\cline{#1}
}
2018-11-04 09:15:58 +00:00
%--
2017-03-19 17:05:13 +00:00
2018-08-19 17:58:59 +00:00
2018-08-20 13:59:45 +00:00
%
%
% Texte
%
%
2017-05-12 19:24:21 +00:00
2020-09-23 18:39:21 +00:00
% \attrib
% Set author, source and date for a text
\newcommand{\attrib}[1]{
\nopagebreak{\raggedleft\footnotesize #1\par}
}
2017-03-19 17:05:13 +00:00
% \hcancel[color][size]{text}
2018-08-20 13:59:45 +00:00
% Strike text with a color and a defined thickness.
\newcommand\hcancel[2][black]{
\setbox0=\hbox{$#2$}%
2017-05-12 19:24:21 +00:00
\rlap{\raisebox{.45\ht0}{\textcolor{#1}{\rule{\wd0}{1pt}}}}#2
}
2016-05-10 19:16:31 +00:00
2017-03-19 17:05:13 +00:00
% \circled{text}
2018-08-20 13:59:45 +00:00
% Circled text.
2017-03-19 17:05:13 +00:00
\newcommand*\circled[1]{
\tikz[baseline=(char.base)]{
\node[shape=circle,draw,inner sep=2pt] (char) {#1};
}
}
2018-10-04 20:32:37 +00:00
% \kbd{text}
2018-08-20 13:59:45 +00:00
% Boxed text as a keyboard key.
% Why: menukeys and tipfr packages don't really run correctly with beamer.
2018-10-04 20:32:37 +00:00
\newcommand*\kbd[1]{%
\tikz[baseline=(key.base)]
\node[%
draw,
fill=white,
drop shadow={shadow xshift=0.25ex,
shadow yshift=-0.25ex,
fill=black,
opacity=0.75},
rectangle,
rounded corners=2pt,
inner sep=1pt,
line width=0.5pt,
font=\scriptsize\sffamily
](key) {#1\strut}
;
}
2017-03-19 17:05:13 +00:00
2018-10-04 20:32:37 +00:00
% \getrandomletter[*]{start}{end}
% Choose a letter between start and end in the alphabetical order.
% Produce a uppercased letter when called with a star.
2018-09-11 05:52:15 +00:00
\NewDocumentCommand \getrandomletter { s G{1} G{26} }{%
\IfBooleanTF { #1 }{
\pgfmathrandominteger{\zzz}{#2}{#3}\csname pgffor@Alpha\endcsname{\zzz}
}{
\pgfmathrandominteger{\zzz}{#2}{#3}\csname pgffor@alpha\endcsname{\zzz}
}
}
2018-10-04 20:32:37 +00:00
% \@getletter{start}{end}
2018-12-08 19:25:10 +00:00
% Choose a letter between start an end.The letter maybe in uppercase or in lowercase.
2018-09-25 04:42:35 +00:00
\NewDocumentCommand \@getletter{ G{1} G{26} }{
\pgfmathsetmacro{\random}{rnd}
\pgfmathparse{\random >= 0.5 ?
"\noexpand\getrandomletter{#1}{#2}" :
"\noexpand\getrandomletter*{#1}{#2}"}
2018-09-11 05:52:15 +00:00
\pgfmathresult
}
2018-10-04 20:32:37 +00:00
% NEED COMMENT
\newsavebox{\fminipagebox}
\NewDocumentEnvironment{fminipage}{m O{\fboxsep}}
{\par\kern#2\noindent\begin{lrbox}{\fminipagebox}
\begin{minipage}{#1}\ignorespaces}
{\end{minipage}\end{lrbox}%
\makebox[#1]{%
\kern\dimexpr-\fboxsep-\fboxrule\relax
\fbox{\usebox{\fminipagebox}}%
\kern\dimexpr-\fboxsep-\fboxrule\relax
}\par\kern#2
}
2018-11-04 09:15:58 +00:00
%--
2018-10-04 20:32:37 +00:00
%
%
% MINTED
%
%
\definecolor{friendlybg}{HTML}{F0F0F0}
\newminted[python]{python}{style=bw,
fontsize=\small,
bgcolor=white,
2019-11-13 17:49:33 +00:00
highlightcolor=white,
autogobble,
2020-08-20 09:42:10 +00:00
frame=none,
% breaklines,
escapeinside=||,
xleftmargin=0em,
xrightmargin=0em,
numbersep=.2em}
2019-11-02 09:50:53 +00:00
2019-11-13 17:49:33 +00:00
\newmintinline{python}{style=bw,
fontsize=\small,
2019-11-13 17:49:33 +00:00
bgcolor=white,
highlightcolor=white,
autogobble,
encoding=utf8}
2019-11-02 09:50:53 +00:00
\renewcommand{\theFancyVerbLine}{
\sffamily\black{\bfseries{\scriptsize\arabic{FancyVerbLine}}}}
2019-11-02 09:50:53 +00:00
\AtBeginEnvironment{minted}{\dontdofcolorbox}
\def\dontdofcolorbox{\renewcommand\fcolorbox[4][]{##4}}
\xpatchcmd{\inputminted}{\minted@fvset}{\minted@fvset\dontdofcolorbox}{}{}
2018-11-04 09:15:58 +00:00
%--
2018-10-04 20:32:37 +00:00
2018-09-11 05:52:15 +00:00
%
%
% BCLOGO
%
%
\renewcommand\bcStyleTitre[1]{\textbf{#1}}
2018-12-08 19:25:10 +00:00
\newcommand\bcexemple{\centering \normalsize \faPaperclip}
\newcommand\bcremarque{\centering \normalsize \faExclamationTriangle}
\newcommand\bclivre{\centering \normalsize \faBook}
\newcommand\bcaide{\centering \normalsize \faInfoCircle}
2018-11-04 09:15:58 +00:00
%--
2018-09-11 05:52:15 +00:00
2018-09-03 14:08:40 +00:00
2018-10-04 20:32:37 +00:00
%
%
2018-10-16 21:08:37 +00:00
% CAPTIONS
2018-09-03 14:08:40 +00:00
%
%
\DeclareCaptionFormat{source}{\textbf{\textit{source#2}} #3}
2018-08-20 13:59:45 +00:00
%---------------------------------------------
% \NewDocumentCommand \hcancel { O{black} O{1pt} } {
% \setbox0=\hbox{$#3$}%
% \rlap{\raisebox{.45\ht0}{\textcolor{#1}{\rule{\wd0}{#2}}}} {#3}
% }
% \NewDocumentCommand \solution { s O{solution} g } {
% \IfBooleanTF {#1}
% {
% \setboolean{display}{true}
% }
% {}
% \begin{#2}
2018-09-11 05:52:15 +00:00
% \end{#2}
2018-08-20 13:59:45 +00:00
% }
%% \underdash[color]{text}
%\newcommand\underdash[1][black]{% <- règle la couleur du texte
% \bgroup
% \ifdim\ULdepth=\maxdimen\settodepth\ULdepth{(j}\advance\ULdepth.4pt\fi
% \markoverwith{\kern0.2em% <- règle l'espacement avant un pointillé
% \vtop{
% \kern0.5ex% <- règle l'altitude des pointillés
% {\color{black}% <- règle la couleur des pointillés
% \hrule width.4em% <- règle la largeur des pointillés
% }
% }
% \kern0.2em% <- règle l'espacement après un pointillé
% }
% \color{#1}\ULon
%}
%---------------------------------------------
2018-11-04 09:15:58 +00:00
%--
2018-08-20 13:59:45 +00:00
%
%
2018-10-16 21:08:37 +00:00
% FONTS
2018-08-20 13:59:45 +00:00
%
%
2017-03-19 17:05:13 +00:00
2021-05-27 10:36:36 +00:00
\ifluatex
\newfontfamily\Annie[Ligatures=TeX]{Annie Use Your Telescope}
\newfontfamily\Architects[Ligatures=TeX]{Architects Daughter}
\newfontfamily\Bristol[Ligatures=TeX]{Bristol}
\newfontfamily\ChelseaMarket[Ligatures=TeX]{Chelsea Market}
\newfontfamily\DejaVuSans[Ligatures=TeX]{DejaVu Sans}
\newfontfamily\dominofont[Ligatures=TeX]{DejaVu Sans}
\newfontfamily\Delius[Ligatures=TeX]{Delius}
\newfontfamily\DeliusSC[Ligatures=TeX]{Delius Swash Caps}
\newfontfamily\FingerPaint[Ligatures=TeX]{Finger Paint}
\newfontfamily\Handlee[Ligatures=TeX]{Handlee}
\newfontfamily\Jd[Ligatures=TeX]{j.d.}
\newfontfamily\Julee[Ligatures=TeX]{Julee}
\newfontfamily\Morse[Ligatures=TeX]{Morse}
\newfontfamily\NixieOne[Ligatures=TeX]{Nixie One}
\newfontfamily\PenguinAttack[Ligatures=TeX]{PenguinAttack}
\newfontfamily\PokemonHollow[Ligatures=TeX]{Pokemon Hollow}
\newfontfamily\PokemonSolid[Ligatures=TeX]{Pokemon Solid}
\newfontfamily\Purisa[Ligatures=TeX]{Purisa}
\newfontfamily\ScratchedLetters[Ligatures=TeX]{Scratched Letters}
\newfontfamily\Lato[Ligatures=TeX]{Lato}
2021-05-27 10:43:48 +00:00
\else
\newcommand\newFontCommand[2]{%
\expandafter\newcommand\csname #1\endcsname{\usefont{T1}{#2}{m}{n}}}
\newFontCommand{Jd}{j.d.}
2021-05-27 10:36:36 +00:00
\fi
2018-08-20 13:59:45 +00:00
%--------------------------------------------------------
% Intent for a more general command.
% \NewDocumentCommand \setFont { O{\familydefault} O{\encodingdefault} }{%
% \fontencoding{#2}%
% \fontfamily{#1}%
% \selectfont
% }
2018-08-20 13:59:45 +00:00
%--------------------------------------------------------
2017-01-03 22:55:55 +00:00
2020-08-13 11:32:00 +00:00
%---
% Print dominos
\newcommand*\d@mino[3]{%
{\dominofont\char
\numexpr #1 + #2*7 + #3
\relax
}}
\newcommand*\domino{\@ifstar{\d@mino{127075}}{\d@mino{127025}}}
%---
2018-11-04 09:15:58 +00:00
%--
2018-08-20 13:59:45 +00:00
%
%
2018-10-16 21:08:37 +00:00
% COLORS
2018-08-20 13:59:45 +00:00
%
%
% \newColorCommand{color}
% Create a macro which can be accessed with the name "\color".
% This macro make the following text to be colored in color.
\newcommand\newColorCommand[1]{%
2021-05-27 10:43:48 +00:00
\expandafter\newcommand\csname #1\endcsname{\color{#1}}}
2018-08-20 13:59:45 +00:00
% Create some color commands
\newColorCommand{red}
2018-09-03 14:08:40 +00:00
\newColorCommand{black}
\newColorCommand{white}
2017-03-29 15:53:10 +00:00
\newColorCommand{gray}
2018-09-03 14:08:40 +00:00
\newColorCommand{lapislazuli}
2018-11-04 09:15:58 +00:00
%--
2018-09-03 14:08:40 +00:00
%
%
2018-10-16 21:08:37 +00:00
% MATHS
2018-09-03 14:08:40 +00:00
%
%
\newcommand\OPoval[3]{%
\dimen1=#2\opcolumnwidth
\ovalnode{#1}
{\kern\dimen1 #3\kern\dimen1}}
%% horizontal or vertical p-uplet
%%
\ExplSyntaxOn
\NewDocumentCommand \uplet { s m } {
\IfBooleanTF { #1 } {
\ensuremath{
\begin{pmatrix}
\uplet_vertical_list:n {#2}
\end{pmatrix}
}
}{
\ensuremath{
\left(
\uplet_inline_list:n {#2}
\right)
}
}
}
% define a sequence for storing the "massaged" items
\seq_new:N \uplet_seq
\cs_new_protected:Npn \uplet_inline_list:n #1
{
% clear the sequence
\seq_clear:N \uplet_seq
% cycle through the arguments, storing "<arg>" in the sequence
\clist_map_inline:nn { #1 }
{
\seq_put_right:Nn \uplet_seq { ##1 }
}
% output the sequence putting ";" in between elements
\seq_use:Nnnn \uplet_seq { \ ;\ } { \ ;\ } { \ ;\ }
}
\cs_new_protected:Npn \uplet_vertical_list:n #1
{
% clear the sequence
\seq_clear:N \uplet_seq
% cycle through the arguments, storing "<arg>" in the sequence
\clist_map_inline:nn { #1 }
{
\seq_put_right:Nn \uplet_seq { ##1 }
}
% output the sequence putting ";" in between elements
\seq_use:Nnnn \uplet_seq { \\ } { \\ } { \\ }
}
\ExplSyntaxOff
2018-11-04 09:15:58 +00:00
%--
2016-03-22 11:49:55 +00:00
2018-12-08 19:25:10 +00:00
% %
% %
% % FIGURES
% %
% %
2018-10-16 21:08:37 +00:00
%
2018-12-08 19:25:10 +00:00
% \NewDocumentCommand \fig { O{1} m }{
% \IfFileExists{#2}{
% \begin{center}
2019-11-02 09:50:53 +00:00
% \includegraphics[scale=#1]{#2}
2018-12-08 19:25:10 +00:00
% \end{center}
% }{
% \begin{center}
% \textbf{Fichier {\normalfont\slshape #2} non trouvé !}
% \end{center}
% }
% }
2018-11-04 09:15:58 +00:00
%--
2018-10-16 21:08:37 +00:00
2016-03-22 11:49:55 +00:00
\makeatother