Fonts & Character SetsRedefine % character mapping

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Post Reply
rhino7890
Posts: 10
Joined: Fri Sep 24, 2010 7:27 pm

Redefine % character mapping

Post by rhino7890 »

I'm trying to remap the % character in mathmode to a different font. Typically, if I were to remap a character, I would do something like this:

Code: Select all

\DeclareSymbolFont{mymathvariables}{<encoding>}{<fontfamily>}{<weight>}{<style>}
\DeclareSymbolFontAlphabet{\mathnormal}{mymathvariables}

\DeclareMathSymbol{$}{\mathalpha}{mymathvariables}{"24}
which would map the "$" character to <fontfamily> in mathmode instead of the default fontfamily. However, remapping the % character is a little tricky as the % character is the comment symbol in LaTeX. So,

Code: Select all

\DeclareMathSymbol{%}{\mathalpha}{mymathvariables}{"25}
doesn't work as the LaTeX parser doesn't interpret anything after the % sign.Likewise, if I try something like this

Code: Select all

\DeclareMathSymbol{\%}{\mathalpha}{mymathvariables}{"25}
I get an error saying that "LaTeX Error Command `\%' already defined."

Does anyone know how to get around this problem? Thanks.
Last edited by rhino7890 on Sun Mar 27, 2011 6:54 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

rhino7890
Posts: 10
Joined: Fri Sep 24, 2010 7:27 pm

Redefine % character mapping

Post by rhino7890 »

So I figured out a solution:

Code: Select all

\catcode`\%=12
\DeclareMathSymbol{%}{\mathpunct}{mymathvariables}{"25}
\catcode`\%=14
For more information on what this is doing, see http://stackoverflow.com/questions/2498 ... -at-symbol.
Post Reply