diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/maybemath |
Initial commit
Diffstat (limited to 'macros/latex/contrib/maybemath')
-rw-r--r-- | macros/latex/contrib/maybemath/README | 34 | ||||
-rw-r--r-- | macros/latex/contrib/maybemath/maybemath.pdf | bin | 0 -> 69595 bytes | |||
-rw-r--r-- | macros/latex/contrib/maybemath/maybemath.sty | 92 | ||||
-rw-r--r-- | macros/latex/contrib/maybemath/maybemath.tex | 98 |
4 files changed, 224 insertions, 0 deletions
diff --git a/macros/latex/contrib/maybemath/README b/macros/latex/contrib/maybemath/README new file mode 100644 index 0000000000..7d3fdf8f3b --- /dev/null +++ b/macros/latex/contrib/maybemath/README @@ -0,0 +1,34 @@ +maybemath LaTeX style, by Andy Buckley <andy@insectnation.org> +-------------------------------------------------------------- + +maybemath provides LaTeX macros for making math bold, upright, italic +or sans-serif according to context. + +The \maybebm and \maybeit macros can be used in math expressions to make +the arguments typeset as bold or italic respectively if the surrounding +context is appropriate. They are useful for writing user macros for use +in general contexts. + +\maybebm is especially appropriate when section titles contain math +expressions, since the title will appear bold but the header and table +of contents usually replicate the title in normal width. + +\maybeit performs a similar role to \mathrm{} but the math expression will +be italicised if the surrounding text is. \maybeitsubscript is provided to +shift subscripts to the left if the expression is italicised. + +\maybesf makes the argument typeset with \mathsf{} if the surrounding text +context is sans-serif. Note that there is no sans-serif italic math font, +so this command is not compatible with any italic-forcing commands. + +A convenience macro, \maybebmsf is available for handling boldness and +sans-serif issues at the same time, as these are probably the most frequent +problematic environments. Other combined handling is possible with nested +use of the above commands. + +Thanks to Viet-Trung Luu on comp.text.tex for providing the first steps +to solving this problem. + +This material is subject to the LaTeX Project Public License. +See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html for +the details of that license.
\ No newline at end of file diff --git a/macros/latex/contrib/maybemath/maybemath.pdf b/macros/latex/contrib/maybemath/maybemath.pdf Binary files differnew file mode 100644 index 0000000000..992de0a342 --- /dev/null +++ b/macros/latex/contrib/maybemath/maybemath.pdf diff --git a/macros/latex/contrib/maybemath/maybemath.sty b/macros/latex/contrib/maybemath/maybemath.sty new file mode 100644 index 0000000000..0cbe49e855 --- /dev/null +++ b/macros/latex/contrib/maybemath/maybemath.sty @@ -0,0 +1,92 @@ +\ProvidesPackage{maybemath}[2005/2/22] +\RequirePackage{amsmath} +\RequirePackage{bm} +%\RequirePackage{xspace} + +%% A few commands for making math fonts bold, upright, italic +%% or sans-serif according to the context of surrounding text. +%% It is particularly useful for avoiding problems with math +%% boldness in section titles causing unwanted boldness +%% in e.g. the table of contents. +%% +%% Thanks to Viet-Trung Luu on comp.text.tex for providing +%% the first steps to solving this problem. +%% +%% This material is subject to the LaTeX Project Public License. +%% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +%% for the details of that license. +%% +%% Author: Andy Buckley <andy@insectnation.org> + + +%% Mode names for bold, ext-bold, italic and sans-serif contexts +\def\@boldname{b}% +\def\@boldexname{bx}% +\def\@italname{it}% +\def\@sfname{cmss}% + + +%% Use the bold symbol if reqd for math fonts +\DeclareRobustCommand{\maybebm}[1]{\ensuremath{% + \ifx\f@series\@boldname% + {{\bm{#1}}}% + \else\ifx\f@series\@boldexname% + {{\bm{#1}}}% + \else% + {{#1}}% + \fi\fi% +}} + +%% Use \mathrm if not in italic context +\DeclareRobustCommand{\mayberm}[1]{\ensuremath{% + \ifx\f@shape\@italname% + {#1}% + \else% + {\mathrm{#1}}% + \fi% +}} + +%% Use \mathit if in italic context +\DeclareRobustCommand{\maybeit}[1]{\ensuremath{% + \ifx\f@shape\@italname% + {\mathit{#1}}% + \else% + {#1}% + \fi% +}} + +%% Use \mathrm if not in italic context +%% and \mathit if in italic context +\DeclareRobustCommand{\maybeitrm}[1]{\ensuremath{% + \ifx\f@shape\@italname% + {\mathit{#1}}% + \else% + {\mathrm{#1}}% + \fi% +}} + +%% Maybe-italic subscript shifting +\DeclareRobustCommand{\maybeitsubscript}[1]{\ensuremath{% + \ifx\f@shape\@italname% + {\!\mspace{1mu}#1}% + \else% + {#1}% + \fi% +}} + +%% Maybe-sans font change +\DeclareRobustCommand{\maybesf}[1]{\ensuremath{% + \ifx\f@family\@sfname% + {\mathsf{#1}}% + \else% + {#1}% + \fi% +}} + +%% Convenience command for following bold and sans-serif contexts +\DeclareRobustCommand{\maybebmsf}[1]{% + {\maybebm{\maybesf{#1}}}% +} + +%% For reference purposes :-) +%\DeclareRobustCommand{\maybemath}{\texttt{maybemath}\xspace} diff --git a/macros/latex/contrib/maybemath/maybemath.tex b/macros/latex/contrib/maybemath/maybemath.tex new file mode 100644 index 0000000000..54e7852c33 --- /dev/null +++ b/macros/latex/contrib/maybemath/maybemath.tex @@ -0,0 +1,98 @@ +\documentclass[12pt]{article} +%\usepackage{setspace} +%\usepackage{booktabs} +\usepackage{maybemath, xspace} +\newcommand{\maybemath}{\texttt{maybemath}\xspace} + +\author{Andy Buckley, \texttt{andy@insectnation.org}} +\title{The \maybemath package for \LaTeX} + +\newcommand{\manifestsAs}{\ensuremath{\Rightarrow\quad}\xspace} +\newcommand{\texcommand}[1]{\texttt{\ensuremath{\backslash{}}{#1}}\xspace} +\newcommand{\texarg}[1]{\ensuremath{\!}\texttt{\{}\textit{#1}\texttt{\}}\xspace} +\newcommand{\maybebmName}{\texcommand{maybebm}} +\newcommand{\maybermName}{\texcommand{mayberm}} +\newcommand{\maybeitName}{\texcommand{maybeit}} +\newcommand{\maybeitrmName}{\texcommand{maybeitrm}} +\newcommand{\maybeitsubscriptName}{\texcommand{maybeitsubscript}} +\newcommand{\maybesfName}{\texcommand{maybesf}} +\newcommand{\maybebmsfName}{\texcommand{maybebmsf}} +\newcommand{\maybemathName}{\texcommand{maybemath}} + +\begin{document} +\maketitle + +The \maybemath package provides a set of commands for adjusting math-mode +typesetting to match the context of the surrounding paragraph. This includes +making the math-mode text bold, upright, forced italic or sans-serif according +to context, or any combination of these. It can be particularly useful when math +terms must appear in section headings, as this implies the same expression +appearing in several boldness contexts: the heading itself, the table of +contents and perhaps a page header or footer. Typically this has been resolved +manually by use of the optional second argument of the sectioning commands: +\maybemath provides a more seamless solution. + +This package was developed in order to implement the \texttt{hepparticles} +package, used for typesetting high-energy physics particle names. +% The commands are intended more for use in flexible macro definitions than +% for direct use in documents, hence the command names are quite verbose. + +The commands available are defined below. In general they may be nested and can +take arbitrarily large arguments within a single math expression. The term to +watch in the expressions below is the $x^3$: + +\section{Bold contexts} +\begin{itemize} +\item For context-sensitive boldness use \maybebmName\texarg{expr}:\\ + {\verb|\dots foo bar, $x^2 + \maybebm{x^3} + \dotsb$|}\\ \manifestsAs {\dots foo bar, $x^2 + \maybebm{x^3} + \dotsb$}\\ + {\verb|\textbf{\dots foo bar, $x^2 + \maybebm{x^3} + \dotsb$}|}\\ \manifestsAs \textbf{\dots foo bar, $x^2 + \maybebm{x^3} + \dotsb$} +\end{itemize} + + +\section{Upright and italic contexts} +\begin{itemize} +\item For context-sensitive upright math typesetting use \maybermName\texarg{expr}:\\ + {\verb|\dots foo bar, $x^2 + \mayberm{x^3} + \dotsb$|}\\ \manifestsAs {\dots foo bar, $x^2 + \mayberm{x^3} + \dotsb$}\\ + {\verb|\textit{\dots foo bar, $x^2 + \mayberm{x^3} + \dotsb$}|}\\ \manifestsAs \textit{\dots foo bar, $x^2 + \mayberm{x^3} + \dotsb$} + +\item Alternatively, to force \texcommand{mathit} in italic contexts use \maybeitName\texarg{expr}:\\ + {\verb|\dots foo bar, $x^2 + \maybeit{x^3} + \dotsb$|}\\ \manifestsAs {\dots foo bar, $x^2 + \maybeit{x^3} + \dotsb$}\\ + {\verb|\textit{\dots foo bar, $x^2 + \maybeit{x^3} + \dotsb$}|}\\ \manifestsAs \textit{\dots foo bar, $x^2 + \maybeit{x^3} + \dotsb$} + +\item The functionality of both \maybermName and \maybeitName is combined for convenience in the command \maybeitrmName\texarg{expr}:\\ + {\verb|\dots foo bar, $x^2 + \maybeitrm{x^3} + \dotsb$|}\\ \manifestsAs {\dots foo bar, $x^2 + \maybeitrm{x^3} + \dotsb$}\\ + {\verb|\textit{\dots foo bar, $x^2 + \maybeitrm{x^3} + \dotsb$}|}\\ \manifestsAs \textit{\dots foo bar, $x^2 + \maybeitrm{x^3} + \dotsb$} + +\item An extra command is available for adjusting the spacing of subscripts in italic contexts: they are shifted + to the left if wrapped with the command \maybeitsubscriptName\texarg{expr}:\\ + {\verb|\dots foo bar, $\mayberm{B_d^0} \to \|\\\verb|\mayberm{B_\maybeitsubscript{d}^0}$|}\\ \manifestsAs {\dots foo bar, $\mayberm{B_d^0} \to \mayberm{B_\maybeitsubscript{d}^0}$}\\ + {\verb|\textit{\dots foo bar, $\mayberm{B_d^0} \to \|\\\verb|\mayberm{B_\maybeitsubscript{d}^0}$}|}\\ \manifestsAs \textit{\dots foo bar, $\mayberm{B_d^0} \to \mayberm{B_\maybeitsubscript{d}^0}$}\\ + I'm not aware if there are particular uses for this outside the pickinesses of particle-name typesetting but it \emph{may} be useful! +\end{itemize} + + +\section{Sans-serif contexts} +\begin{itemize} +\item For context-sensitive sans-serif math typesetting use \maybesfName\texarg{expr}:\\ + {\verb|\dots foo bar, $x^2 + \maybesf{x^3} + \dotsb$|}\\ \manifestsAs {\dots foo bar, $x^2 + \maybesf{x^3} + \dotsb$}\\ + {\verb|\textsf{\dots foo bar, $x^2 + \maybesf{x^3} + \dotsb$}|}\\ \manifestsAs \textsf{\dots foo bar, $x^2 + \maybesf{x^3} + \dotsb$}\\ + Note that there is no italic version of the sans-serif math font, so use of \maybesfName eliminates italic context handling. +\end{itemize} + + +\section{Combined contexts} +\begin{itemize} +\item For combined bold-and-sans-serif context handling, a \maybebmsfName\texarg{expr} command is provided:\\ + {\verb|\dots foo bar, $x^2 + \maybebmsf{x^3} + \dotsb$|}\\ \manifestsAs {\dots foo bar, $x^2 + \maybebmsf{x^3} + \dotsb$}\\ + {\verb|\textbf{\dots foo bar, $x^2 + \maybebmsf{x^3} + \dotsb$}|}\\ \manifestsAs \textbf{\dots foo bar, $x^2 + \maybebmsf{x^3} + \dotsb$}\\ + {\verb|\textsf{\dots foo bar, $x^2 + \maybebmsf{x^3} + \dotsb$}|}\\ \manifestsAs \textsf{\dots foo bar, $x^2 + \maybebmsf{x^3} + \dotsb$}\\ + {\verb|\textbf{\textsf{\dots foo bar, $x^2 + \maybebmsf{x^3} + \dotsb$}}|}\\ \manifestsAs \textbf{\textsf{\dots foo bar, $x^2 + \maybebmsf{x^3} + \dotsb$}}\\ + This is assumed to be the most commonly required combination of context-sensitive math typesetting: most other combinations can be achieved by nesting the primitive \maybemath commands. +\end{itemize} + +%Finally, a \maybemathName command is provided for typesetting the name of the package: +%{\verb|\maybemath|} \manifestsAs \maybemath.\\ + +\noindent Any feedback is appreciated! Email to \texttt{andy@insectnation.org}, please. + +\end{document}
\ No newline at end of file |