summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/ibrackets/ibrackets.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/ibrackets/ibrackets.dtx')
-rw-r--r--macros/latex/contrib/ibrackets/ibrackets.dtx114
1 files changed, 60 insertions, 54 deletions
diff --git a/macros/latex/contrib/ibrackets/ibrackets.dtx b/macros/latex/contrib/ibrackets/ibrackets.dtx
index 8e78228310..15a3e050eb 100644
--- a/macros/latex/contrib/ibrackets/ibrackets.dtx
+++ b/macros/latex/contrib/ibrackets/ibrackets.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% Copyright (C) 2022 by Antoine Missier <antoine.missier@ac-toulouse.fr>
+% Copyright (C) 2022-2023 by Antoine Missier <antoine.missier@ac-toulouse.fr>
%
% This file may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, either version 1.3 of this license
@@ -20,7 +20,7 @@
%<*package>
\NeedsTeXFormat{LaTeX2e}[2005/12/01]
\ProvidesPackage{ibrackets}
- [2022/12/26 v1.1 .dtx ibrackets file]
+ [2023/07/26 v1.2 .dtx ibrackets file]
%</package>
%<*driver>
\documentclass{ltxdoc}
@@ -28,6 +28,7 @@
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[charter]{mathdesign}
+\usepackage{amsmath}
\usepackage{ibrackets}
\usepackage{sectsty}
\usepackage{xcolor}
@@ -81,6 +82,8 @@
% - A bug correction in the README.md file
% - Tiny changes in documentation}
%
+% \changes{v1.2}{2023/07/26}{Minor changes in the documentation}
+%
% \GetFileInfo{ibrackets.sty}
%
% \title{Intelligent brackets \\ The \textsf{ibrackets} package}
@@ -90,12 +93,12 @@
%
% \section{Introduction}
%
-% Open intervals are usually represented with parenthesis $(0, +\infty)$
-% but sometimes we find also
-% square brackets $]0, +\infty[$, for example in French mathematics.
-% When using these, spacing is often unsuitable,
-% e.g.\@ $x \in \mathclose{]} 0, +\infty\mathopen{[}$.
-% This small package redefines brackets symbols $[$ and $]$ for mathematical mode
+% Open intervals are commonly represented with parenthesis, e.g.\@ $(0, +\infty)$
+% but sometimes square brackets are used, especially in French mathematics: $]0, +\infty[$.
+% In that specific case, the space around the square brackets is often inappropriate,
+% as in the expression $x \in \mathclose{]} 0, +\infty\mathopen{[}$.
+% This small package address this issue and
+% redefines brackets symbols $[$ and $]$ for mathematical mode
% to get correct spacing: $x \in ]0, +\infty[$.
%
% \medskip
@@ -103,62 +106,65 @@
% and also in \textsf{frenchmath}~\cite{FR}
% since version 2.1, our previous redefinitions produce however incorrect spacing
% when the left bound of the interval begins with a sign - or +,
-% which was then interpreted as a binary operation. Thus blank
+% which was then interpreted as a binary operation. As a result, blank
% spaces surrounding the sign would have been too large.
-% This problem was pointed out by Jean-François Burnol, and
-% an easy solution, that has been documented, consisted to nest the operator
+% This issue was pointed out by Jean-François Burnol, and
+% an easy solution, that has been documented, consists of nesting the operator
% or the left bound within a pair of braces,
-% e.g.\@ |$x \in ]{-}\infty, 0]$|, or use |\left| and |\right|
+% e.g.\@ |$x \in ]{-}\infty, 0]$|, or using |\left| and |\right|
% or even |\mathopen{]}|.
%
% \medskip
-% Inspired by the \textsf{icomma} package~\cite{ICOMMA} of Walter Schmidt, we now provide
-% an improved bracket definition that works correctly without
-% these pairs of curly brackets.
+% Inspired by Walter Schmidt's \textsf{icomma} package~\cite{ICOMMA}, we now provide
+% an improved bracket definition that works correctly without the need for
+% these pairs of braces.
%
% \medskip
-% Let's also mention other approaches e.g.\@ |\DeclarePairedDelimiters|, a macro from
+% Let's also mention other approaches, such as the |\DeclarePairedDelimiters| macro from
% the \textsf{mathtools} package~\cite{TOOL}, or
-% the \textsf{interval} package~\cite{INT} with his
-% |\interval| macro. Nevertheless our solution is lighter.
+% the \textsf{interval} package~\cite{INT} with its
+% |\interval| macro. However our solution is more lightweight.
%
% \section{Usage}
-% You just have to type intervals in an easy way:
-% |$x\in]0,\pi[\cup]2\pi, 3\pi[$|
-% produce
-% \[ x\in]0, \pi[\cup]2\pi, 3\pi[ \mbox{\quad with \textsf{ibrackets}}, \]
-% instead of
-% \[ x\in\mathclose{]} 0,\pi \mathopen{[}\cup\mathclose{]} 2\pi, 3\pi\mathopen{[}
-% \mbox{\quad without \textsf{ibrackets}}.
-% \]
-%
-% Generally $[$ and $]$ symbols are not defined anymore as delimiters,
-% but as ordinary characters.
-% Thereby a line break could occur between the two square brackets, but
-% it is always possible to transform them
-% into delimiters with |\left| and |\right|.
+% With the \textsf{ibrackets} package, you can easily type intervals. For example the code
+% |$x\in]0,\pi[\cup]2\pi, 3\pi[$| yields
+% \begin{align*}
+% x\in]0, \pi[\cup]2\pi, 3\pi[ &\mbox{\quad with \textsf{ibrackets}}, \\
+% \text{instead of \quad}
+% x\in\mathclose{]} 0,\pi \mathopen{[}\cup\mathclose{]} 2\pi, 3\pi\mathopen{[}
+% &\mbox{\quad without \textsf{ibrackets}}.
+% \end{align*}
+%
+% For the example in the introduction the spacing is now correct with the following simple code:
+% |$x \in ]-\infty, 0]$|, which gives $x \in ]-\infty, 0]$.
%
% \medskip
-% The problem of a sign following the first bracket is solved with this package,
-% so the example in the introduction is simply obtained with |$x \in ]-\infty, 0]$|
-% which gives $x \in ]-\infty, 0]$.
+% In \textsf{ibrackets}, the symbols $[$ and $]$
+% and are not defined by default as delimiters.
+% Therefore, a line break could occur between the two brackets. However,
+% it is always possible to transform them
+% into delimiters using |\left| and |\right|.
%
% \medskip
-% \emph{However, you don't have to leave a space between the first bracket and the sign}: e.g.\@
-% |$x \in ] -\infty, 0]$| yields $x \in ] -\infty, 0]$ with bad spacing around the
-% minus sign.
-% Contrariwise, when you want to write algebra on intervals then
-% \emph{you must leave a blank space between the second bracket and the} +/- \emph{operations},
-% e.g.\@ |$[a, b] + [c, d]$| yields $[a, b] + [c, d]$
-% but |$[a, b]+ [c, d]$| yields $[a, b]+ [c, d]$.
-% To summarize the new behavior of a bracket: it is an ordinary character,
-% but an open delimiter when it is immediately followed by a + or - character.
+% Actually, brackets are set as ``active'' characters,
+% behaving like ordinary characters in most cases.
+% However, when a bracket is \emph{immediately} followed by a + or - character,
+% it becomes an open delimiter. Therefore, when the left bound contains an operator sign,
+% \emph{you don't have to leave a space between the first bracket and the sign},
+% otherwise, the spaces surrounding the operator will be too large.
+% For example if you write |$x \in ] -\infty, 0]$| it yields $x \in ] -\infty, 0]$
+% instead of $x \in ]-\infty, 0]$.
+% Conversely, when dealing with algebraic expressions involving intervals,
+% \emph{you must leave a space between the second bracket and the} +/- \emph{operations}
+% to maintain proper spacing.
+% For instance |$[a, b] + [c, d]$| yields $[a, b] + [c, d]$
+% while |$[a, b]+ [c, d]$| would yield $[a, b]+ [c, d]$.
%
% \StopEventually{}
%
% \section{Implementation}
-% At |\begin{document}|, we memorize the "\mathcode" of the original brackets,
-% in the |\math...bracket| macros, and we make the brackets in math mode active:
+% At |\begin{document}|, we store the original "\mathcode" of the brackets,
+% in the |\math...bracket| macros, and then we make the brackets active in math mode.
% \begin{macrocode}
\AtBeginDocument{%
\mathchardef\mathopenbracket\mathcode`[%
@@ -168,10 +174,10 @@
}
% \end{macrocode}
-% The active brackets check the next input character. If this is a - or a +,
-% the active brackets return |\mathopen| with the saved |\math...bracket|
-% so that no space will be added after the bracket;
-% otherwise, |\mathord\math...bracket| is returned :
+% The active brackets check the next input character. If the next character is a - or a +,
+% the active brackets return |\mathopen| with the saved |\math...bracket|,
+% so that no space will be added after the bracket.
+% Otherwise, |\mathord\math...bracket| is returned.
% \begin{macrocode}
{\catcode`[=\active
\gdef[{\futurelet\@next\sm@rtopenbracket}}
@@ -188,18 +194,18 @@
\mathord\fi\fi \mathclosebracket}
% \end{macrocode}
% We could have use the internal \TeX\ command |\@ifnextchar|
-% to skip blank spaces after the bracket, and look if there is a + or - after,
-% but then it would become tricky when you really want
+% to skip blank spaces after the bracket and look if there is a + or - after,
+% but then it would become tricky when you really want
% to follow an interval with an operation plus or minus.
%
% \begin{thebibliography}{5}
% % \begin{raggedright}
-% \bibitem{MIS} \emph{\textsf{mismath} -- Miscellaneus mathematical macros}.
+% \bibitem{MIS} \emph{\textsf{mismath} -- Miscellaneous mathematical macros}.
% Antoine Missier, CTAN, v2.0 2022/11/11.
% \bibitem{FR} \emph{L'extension \textsf{frenchmath}}. Antoine Missier, CTAN, v2.2 2022/12/15.
% \bibitem{ICOMMA} \emph{The \textsf{icomma} package for \LaTeXe}.
% Walter Schmidt, CTAN, v2.0 2002/03/10.
-% \bibitem{TOOL} \emph{The \textsf{mathtool} package}. Morten Høgholm, Lars Madsen, CTAN,
+% \bibitem{TOOL} \emph{The \textsf{mathtools} package}. Morten Høgholm, Lars Madsen, CTAN,
% v1.21 2018/01/08.
% \bibitem{INT} \emph{The \textsf{interval} package}. Lars Madsen, CTAN,
% v0.4 2019/03/06.