diff options
author | Norbert Preining <norbert@preining.info> | 2024-01-12 03:01:12 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2024-01-12 03:01:12 +0000 |
commit | 1748d1e662c9618cc16f80d5e67669e9e9d6d4be (patch) | |
tree | 7d46019dbae3fa8e0345487ecf524cfc641f1b2a /macros/latex/contrib/medmath | |
parent | b14090c9f3c7797e26fed9eb2b83ce144dcb16a3 (diff) |
CTAN sync 202401120301
Diffstat (limited to 'macros/latex/contrib/medmath')
-rw-r--r-- | macros/latex/contrib/medmath/README | 3 | ||||
-rw-r--r-- | macros/latex/contrib/medmath/medmath.pdf | bin | 0 -> 22985 bytes | |||
-rw-r--r-- | macros/latex/contrib/medmath/medmath.sty | 110 | ||||
-rw-r--r-- | macros/latex/contrib/medmath/medmath.tex | 83 |
4 files changed, 196 insertions, 0 deletions
diff --git a/macros/latex/contrib/medmath/README b/macros/latex/contrib/medmath/README new file mode 100644 index 0000000000..b96bbb99dd --- /dev/null +++ b/macros/latex/contrib/medmath/README @@ -0,0 +1,3 @@ +Package: Fix mediummath option in nccmath package +Author: Jianrui Lyu <tolvjr@163.com> +License: The LaTeX Project Public License 1.3c
\ No newline at end of file diff --git a/macros/latex/contrib/medmath/medmath.pdf b/macros/latex/contrib/medmath/medmath.pdf Binary files differnew file mode 100644 index 0000000000..ddbf48cf4a --- /dev/null +++ b/macros/latex/contrib/medmath/medmath.pdf diff --git a/macros/latex/contrib/medmath/medmath.sty b/macros/latex/contrib/medmath/medmath.sty new file mode 100644 index 0000000000..af6f93165a --- /dev/null +++ b/macros/latex/contrib/medmath/medmath.sty @@ -0,0 +1,110 @@ +% -*- coding: utf-8 -*- +% ---------------------------------------------------------------------------- +% Author: Jianrui Lyu <tolvjr@163.com> +% License: The LaTeX Project Public License 1.3c +% ---------------------------------------------------------------------------- + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{medmath}[2024-01-11 v2024B Fix mediummath option in nccmath package] + +\RequirePackage{array} +\RequirePackage{etoolbox} + +\newif\ifmdm@enabled \mdm@enabledtrue % enable medmath fixes +\newif\ifmdm@amsfonts \mdm@amsfontsfalse % use ams symbol fonts + +\DeclareKeys{ + mdm@enabled .if = mdm@enabled, + mdm@amsfonts .if = mdm@amsfonts +} + +\ProcessKeyOptions + +\RequirePackage[mediummath]{nccmath} + +\newcommand{\my@do@medmath}{% + %% Adjust \oiint operator + \ifdef{\oiint}{% + \let\NCC@op@oiint=\oiint + \DeclareRobustCommand{\oiintop}{\mathop{\medmath{\NCC@op@oiint}}}% + \def\oiint{\DOTSI\NCC@op@prepare{\oiintop}}% + }{}% + %% Setting \medintcorr parameter + %% We have used relative dimensions later, so no need to set it anymore + %\ifmdm@amsfonts + % \medintcorr{0.5em} + %\else + % \medintcorr{0.3em} + %\fi + %% The definite integrals in cases environment may cause infinite loops + %% Our redefinition moves \quad to the beginning of the second columns + %% Therefore removing extra spaces when there is only one column in it + \renewenvironment{cases}{% + \left\{\linespread{1.0}\selectfont\def\arraystretch{1.2}% + \begin{array}{@{}l@{}>{\quad}l@{}}% + }{% + \end{array}\right.% + }% + %% Right skip is missing when minipage or \parbox has only a displayed formula + %% Other problems could be found here: http://tex.stackexchange.com/q/22170 + \let\start@gather=\NCC@startgather + \let\start@align=\NCC@startalign + \let\start@multline=\NCC@startmultline + \let\mathdisplay=\NCC@startdisplay +} + +\newcommand{\my@do@medmath@fix}{% + %% Fix sizes of non integral operators in superscripts/subscripts + %% We use the method in scalerel package for saving math styles + % big operator in normal text is 80% of the size of \displaystyle + % big operator in script is 80% of the size of \textstyle + % big operator in script script is 80% of the size of \scriptstyle + \def\@my@style@D{\displaystyle}% + \def\@my@style@T{\displaystyle}% + \def\@my@style@S{\textstyle}% + \def\@my@style@s{\scriptstyle}% + \def\my@style@saved{\csname @my@style@\@my@style@switch\endcsname}% + \newcommand{\my@style@this}[1]{% + \mathchoice{\def\@my@style@switch{D}##1}{\def\@my@style@switch{T}##1} + {\def\@my@style@switch{S}##1}{\def\@my@style@switch{s}##1}% + }% + \DeclareRobustCommand*\medmath[1]{\NCC@select@msize + \mathord{\my@style@this{\raise\@tempdima\hbox{\NCC@prepare@msize$\my@style@saved ##1$}}}% + } + %% Fix sizes of integral operators in superscripts/subscripts + \newlength{\@my@em}% + \setlength{\@my@em}{1em}% + \ifmdm@amsfonts + \medintcorr{0.5\@my@em}% + \else + \medintcorr{0.3\@my@em}% + \fi + \newcommand{\my@style@unit}[1]{% + \mathchoice{\setlength{\@my@em}{1em}##1}{\setlength{\@my@em}{1em}##1} + {\setlength{\@my@em}{0.5em}##1}{\setlength{\@my@em}{0.3em}##1}% + }% + \let\my@saved@op@printm=\NCC@op@printm + \def\NCC@op@printm{\my@style@unit{\my@saved@op@printm}}% + %% Fix fractions and subfractions in superscripts/subscripts + %% Always use current style size to typeset the fractions + \newcommand{\my@larger@frac}[2]{% + \mathchoice{\genfrac{}{}{}{0}{##1}{##2}}{\genfrac{}{}{}{0}{##1}{##2}}% + {\genfrac{}{}{}{1}{##1}{##2}}{\genfrac{}{}{}{2}{##1}{##2}}% + }% + \DeclareRobustCommand{\frac}[2]{% + \mathchoice{\mfrac{##1}{##2}}{\mfrac{##1}{##2}}% + {\my@larger@frac{##1}{##2}}{\my@larger@frac{##1}{##2}}% + }% + \patchcmd{\NCC@prepare@msize}{% + \def\frac{\protect\NCC@innerfrac{}}% + }{% + \let\frac=\my@larger@frac + }{}{}% +} + +\AtBeginDocument{% + \ifmdm@enabled + \my@do@medmath \my@do@medmath@fix + \fi +} + diff --git a/macros/latex/contrib/medmath/medmath.tex b/macros/latex/contrib/medmath/medmath.tex new file mode 100644 index 0000000000..9f0c2304c2 --- /dev/null +++ b/macros/latex/contrib/medmath/medmath.tex @@ -0,0 +1,83 @@ +% -*- coding: utf-8 -*- +\documentclass[oneside,12pt]{article} +\usepackage[a4paper,margin=2cm]{geometry} + +\newcommand*{\myversion}{2024B} +\newcommand*{\mydate}{Version \myversion\ (\the\year-\mylpad\month-\mylpad\day)} +\newcommand*{\mylpad}[1]{\ifnum#1<10 0\the#1\else\the#1\fi} + +\setlength{\parindent}{0pt} +\setlength{\parskip}{4pt plus 1pt minus 1pt} + +\usepackage{enumerate} +\usepackage{codehigh} +\usepackage{hyperref} +\hypersetup{ + colorlinks=true, + urlcolor=blue3, + linkcolor=green3, +} + +%% The \oiint operator is defined with utopia font +\usepackage[utopia]{mathdesign} + +%\usepackage[mediummath]{nccmath} +\usepackage{medmath} +\makeatletter +\mdm@enabledfalse +\makeatother + +\begin{document} + +\title{\textsf{\color{green3}The \texttt{medmath} package}} +\author{Jianrui Lyu (tolvjr@163.com)} +\date{\mydate} +\maketitle + +\section{The \texttt{mediummath} option in \texttt{nccmath} package} + +There are several problems with \texttt{mediummath} option in \texttt{nccmath} package. + +\begin{enumerate} + \item The big operators in superscripts and subscripts are too large. +\begin{demohigh} +\[A^{\sum_{0}^{1}x}=B\] +\end{demohigh} + \item The definite integrals inside \texttt{cases} environment sometimes cause infinite loops. +\begin{codehigh} +\[\begin{cases} + a & \int_1^t +\end{cases}\] +\end{codehigh} + \item The \verb!\oiint! operators are not scaled to medium size. +\begin{demohigh} +\[\oiint_{\Sigma}xyzdS=\frac{\sqrt{3}}{120}\] +\end{demohigh} +\end{enumerate} + +\section{The \texttt{medmath} package} + +\makeatletter +\my@do@medmath \my@do@medmath@fix +\makeatother + +The \texttt{medmath} package fixes and improves \texttt{mediummath} option in \texttt{nccmath} package. + +\begin{enumerate} + \item The big operators in superscripts and subscripts are in medium size. +\begin{demohigh} +\[A^{\sum_{0}^{1}x}=B\] +\end{demohigh} + \item The definite integrals inside \texttt{cases} environment always work. +\begin{demohigh} +\[\begin{cases} + a & \int_1^t +\end{cases}\] +\end{demohigh} + \item The \verb!\oiint! operators are scaled to medium size. +\begin{demohigh} +\[\oiint_{\Sigma}xyzdS=\frac{\sqrt{3}}{120}\] +\end{demohigh} +\end{enumerate} + +\end{document} |