Difference between revisions of "Bold Math"

From Wiki
Jump to navigation Jump to search
(added MyWay#5 link)
m (remove link to former font page)
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
< [[Math]] | [[Fonts]] >
+
< [[Math]] | [[Bold Typewriter]] >
  
see [http://www.pragma-ade.com/general/magazines/mag-0005.pdf MyWay No.5 about "Mixed Normal and Bold Math"] by Pragma
+
Hans has descibed how to work with bold math in [http://www.pragma-ade.com/general/magazines/mag-0005.pdf MyWay No.5 about "Mixed Normal and Bold Math"].
 +
However, this method only seems to work with lucida fonts. For other fonts (currently only for latin modern and euler), one can also define
  
----
+
<texcode>
 +
\definetypeface [boldmath] [mm] [boldmath] [latin-modern] [default]
 +
</texcode>
  
David Munger wrote in [http://www.ntg.nl/pipermail/ntg-context/2004/005314.html this post] and [http://www.ntg.nl/pipermail/ntg-context/2004/005315.html its followup]:
+
and then use <code>boldsymbol</code> around symbol that you want in bold.
 +
== Mixing Math Fonts ==
  
I've just found a little workaround for using boldsymbols. It works even with the [[Math with nath|nath]] module. It's probably not the best way of doing it, but since it does the trick for me, I guess it might useful to other ConTeXters.
+
<i>This should be better documented and should go into a separate document, but until then I just leave it here before it gets lost. Perhaps the example above could be typeset in a similar way as well.</i>
  
 +
{{Explanation}}
 +
 +
<b>Background</b>: If you use
 
<texcode>
 
<texcode>
\define[1]\boldsymbol{{\hbox{\formula{\bfm #1}}}}
+
\setupbodyfont[ant] % Antykwa Torunska
 
</texcode>
 
</texcode>
 +
the math will be typeset with Antykwa as well. <i>(Perhaps this is a deprecated way of selecting fonts, I don't know. It works on my distribution, but not on the garden. Please use at your own risk.)</i>
  
When using [[Math with nath|nath]], it doesn't work with inline formulae. So in that case,  better use
+
So far so good. You get pretty mathematical symbols mathcing the document style. The problem arises when you want to try something like
 
 
 
<texcode>
 
<texcode>
\unprotect
+
$\Longrightarrow$
\define[1]\boldsymbol{{\hbox{\o@dollar \bfm #1 \o@dollar}}}
 
\protect
 
 
</texcode>
 
</texcode>
  
I also have to:
+
<b>Solution:</b> [[User:Taco|Taco]] provided the following code and comments:
  
 
<texcode>
 
<texcode>
\definebodyfont
+
\starttypescript [math] [antykwa-torunska] [name]
   [17.3pt,14.4pt,12pt,11pt,10pt,9pt,8pt,7pt,6pt,5pt,4pt]
+
   \definefontsynonym [MathRoman]        [ComputerModernMath-Roman]
   [mm]
+
   \definefontsynonym [MathExtension]    [ComputerModernMath-Extension]
   [mrbf=cmbx10 sa 1,
+
   %definefontsynonym [MathItalic]      [ComputerModernMath-Italic]
  exbf=cmex10  sa 1,
+
  \definefontsynonym [MathSymbol]       [ComputerModernMath-Symbol]
  mibf=cmmib10 sa 1,
+
\stoptypescript
  sybf=cmbsy10 sa 1,
 
  mabf=msam10  sa 1]
 
 
 
\setupformulae[method=bold]
 
 
</texcode>
 
</texcode>
  
Then, I may define very handy commands like
+
Since there is more in the MathItalic fonts than just letters, it
 +
may produce un-even effects.
  
<texcode>
+
If you want more detailed control, you have to load extra math
\define\grad{\boldsymbol{\nabla}}
+
font families and redefine selected bits of the math collection
\define[1]\vec{\boldsymbol{#1}}
+
(see also [http://source.contextgarden.net/tex/context/base/font-unk.tex font-unk.tex], [http://source.contextgarden.net/tex/context/base/math-tex.tex math-tex.tex] and [http://source.contextgarden.net/type-syn.tex type-syn.tex])
\define[1]\unitvec{\hat{\vec{#1}}}
 
</texcode>
 
  
and formulas like this typeset perfectly:
+
[[Category:Math]]
 
+
[[Category:Fonts]]
<texcode>
 
\[ \grad h = a \unitvec{n} \]
 
</texcode>
 

Revision as of 18:54, 3 June 2020

< Math | Bold Typewriter >

Hans has descibed how to work with bold math in MyWay No.5 about "Mixed Normal and Bold Math". However, this method only seems to work with lucida fonts. For other fonts (currently only for latin modern and euler), one can also define

\definetypeface [boldmath] [mm] [boldmath] [latin-modern] [default]

and then use boldsymbol around symbol that you want in bold.

Mixing Math Fonts

This should be better documented and should go into a separate document, but until then I just leave it here before it gets lost. Perhaps the example above could be typeset in a similar way as well.


Someone thinks this entry needs some more explanation. (See: Needs Explanation?, To-Do List.)


Background: If you use

\setupbodyfont[ant] % Antykwa Torunska

the math will be typeset with Antykwa as well. (Perhaps this is a deprecated way of selecting fonts, I don't know. It works on my distribution, but not on the garden. Please use at your own risk.)

So far so good. You get pretty mathematical symbols mathcing the document style. The problem arises when you want to try something like

$\Longrightarrow$

Solution: Taco provided the following code and comments:

\starttypescript [math] [antykwa-torunska] [name]
  \definefontsynonym [MathRoman]        [ComputerModernMath-Roman]
  \definefontsynonym [MathExtension]    [ComputerModernMath-Extension]
  %definefontsynonym [MathItalic]       [ComputerModernMath-Italic]
  \definefontsynonym [MathSymbol]       [ComputerModernMath-Symbol]
\stoptypescript

Since there is more in the MathItalic fonts than just letters, it may produce un-even effects.

If you want more detailed control, you have to load extra math font families and redefine selected bits of the math collection (see also font-unk.tex, math-tex.tex and type-syn.tex)