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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

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