Created
April 28, 2020 16:22
-
-
Save JeanOlivier/17a595b1ee20f38af5044d463542665d to your computer and use it in GitHub Desktop.
LaTeX Delimiters with automatic sizing that's easily overridable.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\usepackage{xstring} | |
% Parenthèses communes via commandes avec taille ajustable en argument optionnel | |
% La taille par défaut est automatique | |
% | |
% Tester ainsi: | |
% \p{123} | |
% \p[]{123} | |
% \p[big]{123} | |
% \pc[Big]{123} | |
% \pc[bigg]{123} | |
% \pa[Bigg]{123} | |
% \pa[none]{123} | |
\newcommand{\nicedelim}[4]{% | |
\IfEqCase{#1}{% | |
{\left} {\left #2#4 \right #3}% | |
{\right}{\left #2#4 \right #3}% | |
{} {\left #2#4 \right #3}% | |
{big} {\big #2#4 \big #3}% | |
{Big} {\Big #2#4 \Big #3}% | |
{bigg} {\bigg #2#4 \bigg #3}% | |
{Bigg} {\Bigg #2#4 \Bigg #3}% | |
{none} {#4}% | |
}[\PackageError{nicedelim}{Undefined parenthesis size "#1", supported size are: big, Big, bigg, Bigg, none for no delimiters, or automatic mode using \left, \right, or [].}{}]% | |
} | |
\newcommand{\p}[2][\left]{\nicedelim{#1}{(}{)}{#2}} % p => Parenthèse | |
\newcommand{\pc}[2][\left]{\nicedelim{#1}{[}{]}{#2}} % pc => Parenthèse Carrée | |
\newcommand{\pa}[2][\left]{\nicedelim{#1}{\{}{\}}{#2}} % pa => Parenthèse Accollade | |
\newcommand{\norm}[2][\left]{\nicedelim{#1}{|}{|}{#2}} % norme | |
\newcommand{\mean}[2][\left]{\nicedelim{#1}{\langle}{\rangle}{#2}} % Mean => Moyenne | |
% Convenient | |
\newcommand{\abs}{\norm} % Valeur Absolue | |
\newcommand{\moy}{\mean} % Moyenne en Français |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment