latex-homework/shortcuts/shortcuts.sty
2020-09-23 20:39:21 +02:00

349 lines
7.1 KiB
TeX

%%%
%%%
%%% Extensions : shortcuts.sty
%%% Version : 1.0
%%% Date : 10/05/16
%%% Auteur : Jeff LANCE
%%% Notes : Cette extension peut demander l'ajout de certains packages.
%%% Il est conseillé de l'appeler dans un(e) classe/(package) appelant
%%% elle(lui)-même ces packages.
%%%
%%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{shortcuts}[2016/05/16 Définitions de raccourcis vers des macros
existantes, v1.0]
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
% ENVIRONMENTS
%
%
%% itemize
%%
\newcommand{\bi}{\begin{itemize}}
\newcommand{\ei}{\end{itemize}}
%% enumerate
%%
\newcommand{\be}{\begin{enumerate}}
\newcommand{\ee}{\end{enumerate}}
%% descriptions
%%
\newcommand{\bd}{\begin{description}}
\newcommand{\ed}{\end{description}}
%% columns
%%
\newcommand{\bc}{\begin{columns}}
\newcommand{\ec}{\end{columns}}
%% questions
%%
\newcommand{\bq}{\begin{questions}}
\newcommand{\eq}{\end{questions}}
%% tasks
%%
\newcommand{\bt}{\begin{tasks}}
\newcommand{\et}{\end{tasks}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
% TEXT
%
%
%% positive skip.
%%
\NewDocumentCommand \pskip { G{.2} } {%
\vspace*{+#1cm}
}
%% negative skip.
%%
\NewDocumentCommand \nskip { G{.8} } {%
\vspace*{-#1cm}
}
%% another shortcut to whiting text.
%%
\NewDocumentCommand \ghost { } {%
\white
}
%% c'est-à-dire
%%
\NewDocumentCommand \cad { } {
{c'est-à-dire}
}
\NewDocumentCommand \Cad { } {
{C'est-à-dire}
}
%% textsuperscript and textsubscript
%%
\NewDocumentCommand \tup { g } {
\textsuperscript{#1}
}
\NewDocumentCommand \tub { g } {
\textsubscript{#1}
}
%% smileys
%%
\NewDocumentCommand \wink { } {
{\DejaVuSans 😉}
}
\NewDocumentCommand \lol { } {
{\DejaVuSans 😂}
}
\NewDocumentCommand \sad { } {
{\DejaVuSans 😞}
}
% double quoting
%%
\NewDocumentCommand \og { }{
<<
}
\NewDocumentCommand \fg { }{
>>
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
% MATHS
%
%
%% i & j vectors
%%
\NewDocumentCommand \veci { } {
\ensuremath{ \vec{\imath} }
}
\NewDocumentCommand \vecj { } {
\ensuremath{ \vec{\jmath} }
}
%% basis (i,j)
%%
\RenewDocumentCommand \ij { } {
\ensuremath{ \left(\vec{\imath}\; ;\; \vec{\jmath}\right) }
}
%% frame (O;i;j)
%%
\NewDocumentCommand \oij { } {
\ensuremath{ \left(O\; ;\; \vec{\imath}\; ;\; \vec{\jmath}\right) }
}
%% frame (O;I;I)
%%
\NewDocumentCommand \OIJ { } {
\ensuremath{ \left(O\; ;\; I\; ;\; J\right) }
}
%% frame (O;x;y)
%%
\NewDocumentCommand \oxy { } {
\ensuremath{ \left(O\; ;\; x\; ;\; y\right) }
}
%% vector arrow redefinition
%%
\renewcommand{\Vec}[1]{
\ensuremath{ \overrightarrow{#1\vphantom(} }
}
\renewcommand{\vec}[1]{
\ensuremath{ \overrightarrow{#1\vphantom(} }
}
%% positional notation
%%
\newcommand{\base}[2]{
\ensuremath{ \overline{#1\vphantom(}^{#2} }
}
%% sets: N, Z, D, Q, R\Q and R with possibility to minus some numbers
%%
\NewDocumentCommand \R { s g } {
\IfBooleanTF {#1} {
\IfNoValueTF {#2} {
% \mathchoice{\! \mathbb{R} \setminus \{0\} \!}
% {\ensuremath{ \mathbb{R} \setminus \{0\} }}
% {\! \mathbb{R} \setminus \{0\} \!}
% {\! \mathbb{R} \setminus \{0\} \!}
\ensuremath{\mathbb{R} \setminus \{0\}}
}{
% \mathchoice{\! \mathbb{R} \setminus \{0, #2\} \!}
% {\ensuremath{ \mathbb{R} \setminus \{0, #2\} }}
% {\! \mathbb{R} \setminus \{0, #2\} \!}
% {\! \mathbb{R} \setminus \{0, #2\} \!}
\ensuremath{\mathbb{R} \setminus \{0, #2\}}
}
}{
\IfNoValueTF {#2} {
% \mathchoice{\mathbb{R}}
% {\ensuremath{ \mathbb{R} }}
% {\mathbb{R}}
% {\mathbb{R}}
\ensuremath{ \mathbb{R} }
}{
% \mathchoice{\mathbb{R} \setminus \{#2\}}
% {\ensuremath{ \mathbb{R} \setminus \{#2\} }}
% {\mathbb{R} \setminus \{#2\}}
% {\mathbb{R} \setminus \{#2\}}
\ensuremath{\mathbb{R} \setminus \{#2\}}
}
}
}
\NewDocumentCommand \RQ { } {
\( \mathbb{R} \setminus \mathbb{Q} \)
}
\NewDocumentCommand \Q { s g } {
\IfBooleanTF {#1} {
\IfNoValueTF {#2} {
\ensuremath{\mathbb{Q} \setminus \{0\}}
}{
\ensuremath{\mathbb{Q} \setminus \{0, #2\}}
}
}{
\IfNoValueTF {#2} {
\ensuremath{\mathbb{Q}}
}{
\ensuremath{\mathbb{Q} \setminus \{#2\}}
}
}
}
\NewDocumentCommand \D { s g } {
\IfBooleanTF {#1} {
\IfNoValueTF {#2} {
\ensuremath{\mathbb{D} \setminus \{0\}}
}{
\ensuremath{\mathbb{D} \setminus \{0, #2\}}
}
}{
\IfNoValueTF {#2} {
\ensuremath{\mathbb{D}}
}{
\ensuremath{\mathbb{D} \setminus \{#2\}}
}
}
}
\NewDocumentCommand \Z { s g } {
\IfBooleanTF {#1} {
\IfNoValueTF {#2} {
\ensuremath{\mathbb{Z} \setminus \{0\}}
}{
\ensuremath{\mathbb{Z} \setminus \{0, #2\}}
}
}{
\IfNoValueTF {#2} {
\ensuremath{\mathbb{Z}}
}{
\ensuremath{\mathbb{Z} \setminus \{#2\}}
}
}
}
\NewDocumentCommand \N { s g } {
\IfBooleanTF {#1} {
\IfNoValueTF {#2} {
\ensuremath{\mathbb{N} \setminus \{0\}}
}{
\ensuremath{\mathbb{N} \setminus \{0, #2\}}
}
}{
\IfNoValueTF {#2} {
\ensuremath{\mathbb{N}}
}{
\ensuremath{\mathbb{N} \setminus \{#2\}}
}
}
}
\NewDocumentCommand \C { s g } {
\IfBooleanTF {#1} {
\IfNoValueTF {#2} {
\ensuremath{\mathbb{C} \setminus \{0\}}
}{
\ensuremath{\mathbb{C} \setminus \{0, #2\}}
}
}{
\IfNoValueTF {#2} {
\ensuremath{\mathbb{C}}
}{
\ensuremath{\mathbb{C} \setminus \{#2\}}
}
}
}
%% dot product
%%
\NewDocumentCommand \dotprod{ s g g } {
\IfBooleanTF {#1} {
\ensuremath{
\vec{#2} \cdot \vec{#3}
}
}{
\ensuremath{
\overrightarrow{#1\vphantom(} \cdot \overrightarrow{#2\vphantom(}
}
}
}
%% math letter used as curve name
%%
\NewDocumentCommand \mscr{ G{f} } {
$ \mathscr{#1} $
}
%% point
%%
\NewDocumentCommand \point{ G{A} G{0} G{0} } {
$ #1\big(#2\ ;\ #3\big) $
}
%% cardinal
%%
\NewDocumentCommand \card{ G{E} }{
\text{Card($ #1 $)}
}
%% print the acronym F.I. for "Forme indéterminée" in bold and sans-serif font.
%%
\NewDocumentCommand \FI{ } {
\textsf{\textbf{F.I.}}
}
%% \nicefrac shortcut
%%
\NewDocumentCommand \sfrac{ G{1} G{2} } {
\nicefrac{#1}{#2}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatother