summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/mathpunctspace
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/mathpunctspace
Initial commit
Diffstat (limited to 'macros/latex/contrib/mathpunctspace')
-rw-r--r--macros/latex/contrib/mathpunctspace/README.md39
-rw-r--r--macros/latex/contrib/mathpunctspace/doc/comma0mu-semicolonnat-colonnat.pdfbin0 -> 34502 bytes
-rw-r--r--macros/latex/contrib/mathpunctspace/doc/comma10mu-semicolon20mu-colon30mu.pdfbin0 -> 34516 bytes
-rw-r--r--macros/latex/contrib/mathpunctspace/doc/comma5pt-semicolon5pt-colon5pt.pdfbin0 -> 34507 bytes
-rw-r--r--macros/latex/contrib/mathpunctspace/doc/latexorg.pdfbin0 -> 34507 bytes
-rw-r--r--macros/latex/contrib/mathpunctspace/doc/mathpunctspace.pdfbin0 -> 284368 bytes
-rw-r--r--macros/latex/contrib/mathpunctspace/doc/mathpunctspace.tex120
-rw-r--r--macros/latex/contrib/mathpunctspace/tex/mathpunctspace.sty136
8 files changed, 295 insertions, 0 deletions
diff --git a/macros/latex/contrib/mathpunctspace/README.md b/macros/latex/contrib/mathpunctspace/README.md
new file mode 100644
index 0000000000..f8f4bf65c4
--- /dev/null
+++ b/macros/latex/contrib/mathpunctspace/README.md
@@ -0,0 +1,39 @@
+# Control the Space After Punctuation in Expressions
+
+## Descriptions
+
+We provide a mechanism to control the space after the comma and the semicolon in the expressions.
+
+## Version
+
+1.1
+
+## Usage
+
+### Sample of Preamble
+
+```
+\usepackage[comma= L mu, semicolon= M mu, colon= N mu]{mathpunctspace}% L, M, N = as you like
+```
+
+### Options
+
+ * unit: mt or other (default: mu)
+ * comma: substitute keyword natural or skip (default: natural)
+ * semicolon: substitute keyword natural or skip (default: natural)
+ * colon: substitute keyword natural or skip (default: natural)
+ * latexorg: original behavior of LaTeX
+
+Remark: keyword ``natural'' mean the spacing of the in-line.
+
+## Author
+
+Yuwsuke Kieda
+
+## License
+
+BSD 2-Clause License
+
+## Repository
+
+https://github.com/yuw/texmf-mathpunctspace
diff --git a/macros/latex/contrib/mathpunctspace/doc/comma0mu-semicolonnat-colonnat.pdf b/macros/latex/contrib/mathpunctspace/doc/comma0mu-semicolonnat-colonnat.pdf
new file mode 100644
index 0000000000..9a41cf87da
--- /dev/null
+++ b/macros/latex/contrib/mathpunctspace/doc/comma0mu-semicolonnat-colonnat.pdf
Binary files differ
diff --git a/macros/latex/contrib/mathpunctspace/doc/comma10mu-semicolon20mu-colon30mu.pdf b/macros/latex/contrib/mathpunctspace/doc/comma10mu-semicolon20mu-colon30mu.pdf
new file mode 100644
index 0000000000..ccabf70eca
--- /dev/null
+++ b/macros/latex/contrib/mathpunctspace/doc/comma10mu-semicolon20mu-colon30mu.pdf
Binary files differ
diff --git a/macros/latex/contrib/mathpunctspace/doc/comma5pt-semicolon5pt-colon5pt.pdf b/macros/latex/contrib/mathpunctspace/doc/comma5pt-semicolon5pt-colon5pt.pdf
new file mode 100644
index 0000000000..7fa9674752
--- /dev/null
+++ b/macros/latex/contrib/mathpunctspace/doc/comma5pt-semicolon5pt-colon5pt.pdf
Binary files differ
diff --git a/macros/latex/contrib/mathpunctspace/doc/latexorg.pdf b/macros/latex/contrib/mathpunctspace/doc/latexorg.pdf
new file mode 100644
index 0000000000..614c32dcc6
--- /dev/null
+++ b/macros/latex/contrib/mathpunctspace/doc/latexorg.pdf
Binary files differ
diff --git a/macros/latex/contrib/mathpunctspace/doc/mathpunctspace.pdf b/macros/latex/contrib/mathpunctspace/doc/mathpunctspace.pdf
new file mode 100644
index 0000000000..b31c5c0854
--- /dev/null
+++ b/macros/latex/contrib/mathpunctspace/doc/mathpunctspace.pdf
Binary files differ
diff --git a/macros/latex/contrib/mathpunctspace/doc/mathpunctspace.tex b/macros/latex/contrib/mathpunctspace/doc/mathpunctspace.tex
new file mode 100644
index 0000000000..73a3ac22b4
--- /dev/null
+++ b/macros/latex/contrib/mathpunctspace/doc/mathpunctspace.tex
@@ -0,0 +1,120 @@
+\documentclass{article}
+
+\usepackage{lmodern}
+\usepackage[T1]{fontenc}
+\usepackage[nosetpagesize]{graphicx}
+\usepackage{mathpunctspace}
+
+\title{Control the Space After Punctuation in Expressions}
+\author{Yuwsuke Kieda}
+\date{2018/02/27 v1.1}
+
+\begin{document}
+\maketitle
+
+\section{Descriptions}
+
+We provide a mechanism to control the space after the comma in the expressions.
+
+\section{Usage}
+
+\subsection{Sample of Preamble}
+
+\begin{verbatim}
+\usepackage{mathpunctspace}
+\end{verbatim}
+
+\subsection{Options}
+
+\begin{itemize}
+ \item unit: mu or other (default: mu)
+ \item comma: substitute keyword ``natural'' or skip (default: natural)
+ \item semicolon: substitute keyword ``natural'' or skip (default: natural)
+ \item colon: substitute keyword ``natural'' or skip (default: natural)
+ \item latexorg: original behavior of LaTeX
+\end{itemize}
+
+Remark: keyword ``natural'' mean the spacing of the in-line.
+
+\section{License}
+
+BSD 2-Clause License
+
+\section{Repository}
+
+\texttt{https://github.com/yuw/texmf-mathpunctspace}
+
+\section{Samples}
+
+
+\subsection{Sources}
+
+\begin{verbatim}
+Lorem ipsum $(x, y)$, dolor sit amet.
+
+Lorem ipsum $\{x; x \in A\}$; dolor sit amet.
+
+Lorem ipsum $f\colon g \to h$: dolor sit amet.
+\end{verbatim}
+
+\subsection{Sample of Options and Results}
+
+\begin{verbatim}
+\usepackage[latexorg]{mathpunctspace}
+\end{verbatim}
+
+\includegraphics{latexorg.pdf}
+
+\begin{verbatim}
+\usepackage{mathpunctspace}
+% same: comma=natural,semicolon=natural,colon=natural
+\end{verbatim}
+
+Lorem ipsum $(x, y)$, dolor sit amet.
+
+Lorem ipsum $\{x; x \in A\}$; dolor sit amet.
+
+Lorem ipsum $f\colon g \to h$: dolor sit amet.
+
+\begin{verbatim}
+\usepackage[comma=10mu,semicolon=20mu,colon=30mu]{mathpunctspace}
+\end{verbatim}
+
+\includegraphics{comma10mu-semicolon20mu-colon30mu.pdf}
+
+\begin{verbatim}
+\usepackage[unit=pt,comma=5pt,semicolon=5pt,colon=5pt]{mathpunctspace}
+\end{verbatim}
+
+\includegraphics{comma5pt-semicolon5pt-colon5pt.pdf}
+
+\begin{verbatim}
+\usepackage[comma=0mu,semicolon=natural,colon=natural]{mathpunctspace}
+\end{verbatim}
+
+\includegraphics{comma0mu-semicolonnat-colonnat.pdf}
+
+\section{Risks}
+
+If the option (\texttt{comma=10mu}) is given as follows, ``right'' output can not be obtained. See \textit{The \TeX{}book} p.~134.
+
+\begin{verbatim}
+\usepackage[comma=10mu]{mathpunctspace}
+\end{verbatim}
+
+\begin{center}
+ \makeatletter
+ \begingroup
+ \catcode`\,=\active
+ \def\@x@{\def,{\thinmuskip20mu\normalcomma}}%
+ \expandafter\endgroup\@x@%
+% \catcode`\,=\active
+% \def\@x@{\def,{\normalcomma\mskip10mu}}%
+% \expandafter\endgroup\@x@%
+ \makeatother
+ \setbox9\hbox{,}%
+ Input: \verb!$1{,}000$!\qquad
+ Output: $1{,}000$\quad $1,000$
+\end{center}
+
+\end{document}
diff --git a/macros/latex/contrib/mathpunctspace/tex/mathpunctspace.sty b/macros/latex/contrib/mathpunctspace/tex/mathpunctspace.sty
new file mode 100644
index 0000000000..c7da8a4b57
--- /dev/null
+++ b/macros/latex/contrib/mathpunctspace/tex/mathpunctspace.sty
@@ -0,0 +1,136 @@
+\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+\ProvidesPackage{mathpunctspace}
+ [2018/02/27 v1.1 style file ``mathpunctspace.sty''^^J
+ by Yuwsuke Kieda]
+
+\RequirePackage{xkeyval}
+
+\newif\ifm@th@p@s@postspace@comma@natural \m@th@p@s@postspace@comma@naturaltrue
+\newif\ifm@th@p@s@postspace@colon@natural \m@th@p@s@postspace@colon@naturaltrue
+\newif\ifm@th@p@s@postspace@semicolon@natural \m@th@p@s@postspace@semicolon@naturaltrue
+\newif\ifm@th@p@s@unit@mu \m@th@p@s@unit@mutrue
+\DeclareOptionX{comma}[natural]{\def\m@th@p@s@comma@postskip{#1}}
+\DeclareOptionX{colon}[natural]{\def\m@th@p@s@colon@postskip{#1}}
+\DeclareOptionX{semicolon}[natural]{\def\m@th@p@s@semicolon@postskip{#1}}
+\DeclareOptionX{unit}[mu]{\def\m@th@p@s@unit@space{#1}}
+\DeclareOptionX{latexorg}{\endinput}
+
+\ProcessOptionsX
+
+\@ifundefined{m@th@p@s@comma@postskip}{\def\m@th@p@s@comma@postskip{natural}}{}
+\@ifundefined{m@th@p@s@colon@postskip}{\def\m@th@p@s@colon@postskip{natural}}{}
+\@ifundefined{m@th@p@s@semicolon@postskip}{\def\m@th@p@s@semicolon@postskip{natural}}{}
+\@ifundefined{m@th@p@s@unit@space}{\def\m@th@p@s@unit@space{mu}}{}
+
+\def\@tmpm@th@p@s@unit@mu{mu}
+\ifx\m@th@p@s@unit@space\@tmpm@th@p@s@unit@mu\m@th@p@s@unit@mutrue\else\m@th@p@s@unit@mufalse\fi
+
+\setbox\@tempboxa\hbox{$\mskip\thinmuskip$}%
+\def\m@th@p@s@comma@postskip@natural{natural}
+\ifx\m@th@p@s@comma@postskip\m@th@p@s@comma@postskip@natural
+ \newskip\m@th@p@s@postspace@comma
+ \def\m@th@p@s@comma@postskip{%
+ \dimexpr\fontdimen2\the\font-\wd\@tempboxa\relax
+ plus \fontdimen3\the\font
+ minus \fontdimen4\the\font}
+\else
+ \m@th@p@s@postspace@comma@naturalfalse
+ \ifm@th@p@s@unit@mu
+ \newmuskip\m@th@p@s@postspace@comma
+ \else
+ \newskip\m@th@p@s@postspace@comma
+ \fi
+\fi
+
+\setbox\@tempboxa\hbox{$\mskip\thinmuskip$}%
+\def\@colon@postskip@natural{natural}
+\ifx\m@th@p@s@colon@postskip\@colon@postskip@natural
+ \newskip\m@th@p@s@postspace@colon
+ \def\m@th@p@s@colon@postskip{%
+ \dimexpr\fontdimen2\the\font-\wd\@tempboxa\relax
+ plus \fontdimen3\the\font
+ minus \fontdimen4\the\font}
+\else
+ \m@th@p@s@postspace@colon@naturalfalse
+ \ifm@th@p@s@unit@mu
+ \newmuskip\m@th@p@s@postspace@colon
+ \else
+ \newskip\m@th@p@s@postspace@colon
+ \fi
+\fi
+
+\setbox\@tempboxa\hbox{$\mskip\thinmuskip$}%
+\def\@semicolon@postskip@natural{natural}
+\ifx\m@th@p@s@semicolon@postskip\@semicolon@postskip@natural
+ \newskip\m@th@p@s@postspace@semicolon
+ \def\m@th@p@s@semicolon@postskip{%
+ \dimexpr\fontdimen2\the\font-\wd\@tempboxa\relax
+ plus \fontdimen3\the\font
+ minus \fontdimen4\the\font}
+\else
+ \m@th@p@s@postspace@semicolon@naturalfalse
+ \ifm@th@p@s@unit@mu
+ \newmuskip\m@th@p@s@postspace@semicolon
+ \else
+ \newskip\m@th@p@s@postspace@semicolon
+ \fi
+\fi
+
+\m@th@p@s@postspace@comma\m@th@p@s@comma@postskip\relax
+\m@th@p@s@postspace@colon\m@th@p@s@colon@postskip\relax
+\m@th@p@s@postspace@semicolon\m@th@p@s@semicolon@postskip\relax
+
+\begingroup
+\catcode`\,=\active
+\ifm@th@p@s@postspace@comma@natural
+ \def\@x@{\def,{\normalcomma\hskip\m@th@p@s@postspace@comma}}
+\else
+ \ifm@th@p@s@unit@mu
+ \def\@x@{\def,{\thinmuskip\m@th@p@s@postspace@comma\normalcomma}}
+ \else
+ \def\@x@{\def,{\normalcomma\hskip\m@th@p@s@postspace@comma}}
+ \fi
+\fi
+\expandafter\endgroup\@x@%
+% *only* in math-mode are made active...
+\mathcode`\,="8000
+% last space is *necessary*
+\def\normalcomma{\mathchar"613B }
+
+\begingroup
+\catcode`\;=\active
+\ifm@th@p@s@postspace@semicolon@natural
+ \def\@x@{\def;{\normalsemicolon\hskip\m@th@p@s@postspace@semicolon}}
+\else
+ \ifm@th@p@s@unit@mu
+ \def\@x@{\def;{\normalsemicolon\mskip\m@th@p@s@postspace@semicolon}}
+ \else
+ \def\@x@{\def;{\normalsemicolon\hskip\m@th@p@s@postspace@semicolon}}
+ \fi
+\fi
+\expandafter\endgroup\@x@%
+% *only* in math-mode are made active...
+\mathcode`\;="8000
+% last space is *necessary*
+\def\normalsemicolon{\mathchar"603B }
+
+\begingroup
+\catcode`\:=\active
+\ifm@th@p@s@postspace@colon@natural
+ \def\@x@{\def:{\normalcolon\hskip\m@th@p@s@postspace@colon}}
+\else
+ \ifm@th@p@s@unit@mu
+ \def\@x@{\def:{\normalcolon\mskip\m@th@p@s@postspace@colon}}
+ \else
+ \def\@x@{\def:{\normalcolon\hskip\m@th@p@s@postspace@colon}}
+ \fi
+\fi
+\expandafter\endgroup\@x@%
+% *only* in math-mode are made active...
+\mathcode`\:="8000
+% last space is *necessary*
+\def\normalcolon{\mathchar"603A }
+
+\renewcommand\colon{\mathpunct{:}}
+
+\endinput