]> git.lyx.org Git - lyx.git/commitdiff
Use macros with parameters for modulo macros
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 18 Jul 2023 12:27:24 +0000 (14:27 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 21 Jul 2023 21:58:28 +0000 (23:58 +0200)
It turns out that it is possible to use macros with parameters in lib/symbols.

I use this to simplify the use of mod-like macros.

Update documentation.

lib/doc/Math.lyx
lib/symbols

index 0f1460934ff445cf5b530d80e43cdea5a5fc1755..a9fbcf9d1735b3184aa7652af1269ff17de4eaca 100644 (file)
@@ -236,6 +236,7 @@ logicalmkup
 \docbook_mathml_prefix 1
 \author -584632292 "Richard Kimberly Heck"
 \author -563046850 "Jean-Marc LASGOUTTES"
+\author -495245474 "Jean-Marc Lasgouttes"
 \author 177693 "x"
 \author 5863208 "ab"
 \author 47243155 "Jean-Marc"
@@ -29069,24 +29070,257 @@ modulo-
 \begin_layout Standard
 The modulo-function is special,
  because it exists in four variants.
- The variants in a displayed formula are:
+ The variants in a
+\change_deleted -495245474 1689684546
+ displayed
+\change_inserted -495245474 1689684548
+n inline
+\change_unchanged
+ formula are:
+\change_deleted -495245474 1689684526
+
 \begin_inset Formula 
 \begin{align*}
 \underline{\textrm{Command}\raisebox{-0.9mm}{}} &  & \underline{\textrm{Result}}\\
-\mathrm{a\backslash mod\textrm{␣}b} &  & a\mod b\\
-\mathrm{a\backslash pmod\textrm{␣}b} &  & a\pmod b\\
-\mathrm{a\backslash bmod\textrm{␣}b} &  & a\bmod b\\
-\mathrm{a\backslash pod\textrm{␣}b} &  & a\pod b
+\mathrm{a\backslash mod\textrm{␣}b\textrm{␣}} &  & a\mod b\\
+\mathrm{a\backslash pmod\textrm{␣}b\textrm{␣}} &  & a\pmod b\\
+\mathrm{a\backslash bmod\textrm{␣}b\textrm{␣}} &  & a\bmod b\\
+\mathrm{a\backslash pod\textrm{␣}b\textrm{␣}} &  & a\pod b
 \end{align*}
 
 \end_inset
 
 
+\change_inserted -495245474 1689684215
+
 \end_layout
 
 \begin_layout Standard
-In an inline formula less space is set before the function names for all variants.
- By default the modulo-functions take only the first character following the command into account.
+\noindent
+\align center
+
+\change_inserted -495245474 1689684215
+\begin_inset Tabular
+<lyxtabular version="3" rows="5" columns="2">
+<features booktabs="true" tabularvalignment="middle">
+<column alignment="left" valignment="top" width="0pt">
+<column alignment="block" valignment="top">
+<row>
+<cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\change_inserted -495245474 1689684215
+Command
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\change_inserted -495245474 1689684215
+Result
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row>
+<cell alignment="left" valignment="top" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\change_inserted -495245474 1689684286
+a
+\backslash
+mod
+\begin_inset space \textvisiblespace{}
+\end_inset
+
+b
+\change_unchanged
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\change_inserted -495245474 1689684457
+\begin_inset Formula $a\mod b$
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row>
+<cell alignment="left" valignment="top" leftline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\change_inserted -495245474 1689684416
+a
+\backslash
+pmod
+\begin_inset space \textvisiblespace{}
+\end_inset
+
+b
+\begin_inset space \textvisiblespace{}
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" leftline="true" rightline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\change_inserted -495245474 1689684474
+\begin_inset Formula $a\pmod b$
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row change="inserted -495245474 1689684088">
+<cell alignment="center" valignment="top" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\change_inserted -495245474 1689684419
+a
+\backslash
+bmod
+\begin_inset space \textvisiblespace{}
+\end_inset
+
+b
+\begin_inset space \textvisiblespace{}
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\change_inserted -495245474 1689684488
+\begin_inset Formula $a\bmod b$
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+<row change="inserted -495245474 1689684088">
+<cell alignment="center" valignment="top" bottomline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\change_inserted -495245474 1689684421
+a
+\backslash
+pod
+\begin_inset space \textvisiblespace{}
+\end_inset
+
+b
+\begin_inset space \textvisiblespace{}
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+<cell alignment="center" valignment="top" bottomline="true" usebox="none">
+\begin_inset Text
+
+\begin_layout Plain Layout
+
+\change_inserted -495245474 1689684502
+\begin_inset Formula $a\pod b$
+\end_inset
+
+
+\end_layout
+
+\end_inset
+</cell>
+</row>
+</lyxtabular>
+
+\end_inset
+
+
+\change_unchanged
+
+\end_layout
+
+\begin_layout Standard
+In a
+\change_deleted -495245474 1689684554
+n inline
+\change_inserted -495245474 1689684556
+ display
+\change_unchanged
+ formula
+\change_inserted -495245474 1689684559
+,
+
+\change_unchanged
+\change_deleted -495245474 1689684562
+less
+\change_inserted -495245474 1689684563
+more
+\change_unchanged
+ space is set before the function names for all variants
+\change_inserted -495245474 1689684688
+ but 
+\series bold
+
+\backslash
+mod.
+
+\series default
+ This later version is also the only one that does not take the 
+\series bold
+b
+\series default
+ as argument but acts as a binary operator
+\change_unchanged
+.
+\change_deleted -495245474 1689684609
+By default the modulo-functions take only the first character following the command into account.
  To use more than one character,
  put them in \SpecialChar TeX
  braces:
@@ -29100,6 +29334,8 @@ In an inline formula less space is set before the function names for all variant
 \end_inset
 
 
+\change_unchanged
+
 \end_layout
 
 \begin_layout Section
index 293c7291b4ec639d4d03a98b9b5506a249dfa56d..207741ad583d8ba4df973cb807591d3dd565e342 100644 (file)
@@ -11,7 +11,7 @@
 # Note that the first argument of \def must not uses braces, and the second
 # must use braces.
 #
-# syntax: Either
+# syntax: (note that there should be no space character in the definition)
 # \def\macroname{definition}
 # or
 # \def\macroname{definition} requires
 # ("" for empty strings is not supported. One would have to use x for fields
 # that are not set.)
 #
+# It is also possible to use parameters for the macros
+# \def\macroname#1{definition using #1}
+#
+# TODO: Devise a mechanism to represent these in DocBook/XHTML
+#
 # If you put any symbol with a requirement inside an iffont clause, you
 # must put an alternative definition with the same requirement in the
 # corresponding else clause. Otherwise the LaTeX output would depend on the
@@ -1115,12 +1120,19 @@ exp                lyxblacktext  0   0 func     x
 Pr                 lyxblacktext  0   0 funclim  x
 gcd                lyxblacktext  0   0 funclim  x
 deg                lyxblacktext  0   0 func     x
-mod                lyxblacktext  0   0 func     x     amsmath
-bmod               lyxblacktext  0   0 func     x
-pmod               lyxblacktext  0   0 func     x
-pod                lyxblacktext  0   0 func     x     amsmath
 
 
+#
+# Modulo notation
+#
+
+# the original definitions have spacing differences between display/inline/script,
+# but we cannot reproduce that here
+\def\bmod{\mkern1mu\mathbin{\textrm{mod}}\mkern1mu}
+\def\pmod#1{\mkern18mu(\textrm{mod}\mkern6mu#1)}
+\def\pod#1{\mkern18mu(#1)} amsmath
+\def\mod#1{\mkern12mu\textrm{mod}\mkern6mu#1} amsmath
+
 # mathtools.sty
 vcentcolon         cmr          58  58    mathrel :          mathtools
 ordinarycolon      cmr          58  58    mathrel :          mathtools