summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-11-13 22:50:57 +0000
committerKarl Berry <karl@freefriends.org>2018-11-13 22:50:57 +0000
commitcaa540d3bd4bf29e24b6b489629f0a57b4e29dfe (patch)
tree7fb0c88ba197462094e58167677d92d67c8420b5 /Master/texmf-dist/tex
parent5f97f13bf9ebf60fb05b259ac1671e1534aa62ec (diff)
eqexpl (13nov18)
git-svn-id: svn://tug.org/texlive/trunk@49151 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/eqexpl/eqexpl.sty72
1 files changed, 72 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/eqexpl/eqexpl.sty b/Master/texmf-dist/tex/latex/eqexpl/eqexpl.sty
new file mode 100644
index 00000000000..e07d7d9797b
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/eqexpl/eqexpl.sty
@@ -0,0 +1,72 @@
+\ProvidesPackage{eqexpl}[2018/11/11 v.1]
+\RequirePackage{etoolbox}
+\RequirePackage{calc}
+
+%% Spaces between elements
+\newlength{\eqexplSpaceWidth}
+\newcommand{\eqexplSetSpace}[1]{%
+ \setlength{\eqexplSpaceWidth}{\ifstrempty{#1}{2mm}{#1}}%
+}
+\eqexplSetSpace{}
+
+%% Width of 'intro' (typ. 'where')
+\newcommand{\eqexplSetIntro}[1]{%
+ \def\eqexplIntro{#1}%
+}
+\eqexplSetIntro{}
+
+%% Width of delimiter
+\newcommand{\eqexplSetDelim}[1]{%
+ \def\eqexplDelim{#1}%
+}
+\eqexplSetDelim{---}
+
+%% Width of item
+\newcommand{\eqexplSetItemWidth}[1]{%
+ \def\eqexplItemWidth{#1}%
+}
+\eqexplSetItemWidth{5mm}
+
+%% Align of item
+\newcommand{\eqexplSetItemAlign}[1]{%
+ \def\eqexplItemAlign{#1}%
+}
+\eqexplSetItemAlign{r}
+
+\newlength{\itemWidth}
+\newlength{\leftSideWidth}
+
+\newenvironment{eqexpl}[1][\eqexplItemWidth]{%
+ \let\olditem\item%
+ \setlength{\itemWidth}{#1}%
+ \setlength{\leftSideWidth}{\ifdefempty{\eqexplIntro}{}{\widthof{\eqexplIntro}+%
+ \eqexplSpaceWidth+}%
+ \itemWidth+%
+ \eqexplSpaceWidth+%
+ \widthof{\eqexplDelim}+%
+ \eqexplSpaceWidth}%
+ \newtoggle{eqexplFirstItem}%
+ \toggletrue{eqexplFirstItem}%
+ \renewcommand{\item}[1]{%
+ \olditem \makebox[\leftSideWidth]{%
+ \ifdefempty{\eqexplIntro}{}{
+ \makebox[\widthof{\eqexplIntro}][l]{\iftoggle{eqexplFirstItem}{\eqexplIntro}{}}%
+ \hspace{\eqexplSpaceWidth}%
+ }
+ \makebox[\itemWidth][\eqexplItemAlign]{##1}%
+ \hspace{\eqexplSpaceWidth}%
+ \makebox[\widthof{\eqexplDelim}][c]{\eqexplDelim}%
+ \hspace{\eqexplSpaceWidth}%
+ }%
+ \togglefalse{eqexplFirstItem}%
+ \ignorespaces% https://tex.stackexchange.com/a/44062
+ }%
+ \begin{list}{}{\setlength{\parsep}{0pt}%
+ \setlength{\topsep}{0pt}%
+ \setlength{\itemsep}{0pt}%
+ \setlength{\labelsep}{0pt}%
+ \setlength{\leftmargin}{\leftSideWidth}%
+ \setlength{\itemindent}{-\leftSideWidth}}}{%
+ \end{list}
+}
+\endinput