# Visually highlighting symbolic material

I have a diagram in which I need to indicate the difference between symbolic mathematics and English words (potentially to someone who doesn't know about it):

Colour works beautifully for making this distinction. Unfortunately, for the version that is going to go in a book, I can't use colour and have been told not to use greyscale (which was my first fallback). I've tried bold, but it looks pretty horrible and doesn't highlight the distinction terribly well:

(Also bold is bad because sometimes it has mathematical significance.)

Underlining just looks really horrible:

I would be very grateful for any alternative suggestions on how to visually highlight symbolic material.

Source in case it's useful:

\documentclass{article}
\usepackage{xcolor}
\usepackage{framed}
\begin{document}

\definecolor{textual-colour}{rgb}{0,0,0}
\definecolor{symbolic-colour}{rgb}{0.2,0.2,0.9}
\newcommand{\marktextual}[1]{{\color{textual-colour}#1}}
\newcommand{\marksymbolic}[1]{{\color{symbolic-colour}#1}}

\begin{framed}
\marktextual{{If}  \marksymbolic{$K \leq G$} {and} {there} {are} {inclusions} \marksymbolic{$gKg^{-1}\leq K$}  {for} {every} \marksymbolic{$g\in G$}, {then} \marksymbolic{$K \triangleleft G$}: {replacing} \marksymbolic{$g$} {by} \marksymbolic{$g^{-1}$}, {we} {have} {the} {inclusion} \marksymbolic{$g^{-1}Kg\leq K$}, {and} {this} {gives} {the} {reverse} {inclusion} \marksymbolic{$K\leq gKg^{-1}$}.}
\smallskip

\marktextual{{The} {kernel} \marksymbolic{$K$} {of} {a} {homomorphism} \marksymbolic{$f:G\rightarrow H$} {is} {a} {normal}  {subgroup}: {if} \marksymbolic{$a\in K$}, {then} \marksymbolic{$f(a)=1$}; {if} \marksymbolic{$g\in G$}, {then} \marksymbolic{$f(gag^{-1}) = f(g)f(a)f(g^{-1}) = f(g)f(g^{-1}) = 1$}, {and} {so} \marksymbolic{$gag^{-1}\in K$}. {Hence}, \marksymbolic{$gKg^{-1}\leq K$}  {for} {all} \marksymbolic{$g\in G$}, {and} {so} \marksymbolic{$K \triangleleft G$}. {Conversely}, {we} {shall} {see} {later} {that} {every} {normal} {subgroup} {is} {the} {kernel} {of} {some} {homomorphism}.}
\end{framed}\end{document}


Edit: while I was trying to keep this short, from the comments it looks like a little more explanation of the context is necessary. The text of the book says:

"At first sight, the most striking feature of mathematical language is the way in which it mixes material that looks as if it is drawn from a natural language with material built up out of idiosyncratically mathematical symbols. The distinction is illustrated in Figure 2.1."

Figure 2.1 looks like this:

-
For centuries math formulas have not been emphasized in any particular way other than using italics for the letters. – egreg Jan 2 '13 at 18:07
@egreg: I've written a book on the language of mathematics and I'm trying to explain the difference between symbolic material and words to someone who doesn't necessarily know any maths. Italicisation isn't enough, because e.g. the various operators aren't clearly indicated as being symbolic. – Mohan Jan 2 '13 at 18:07
Sorry, but I don't get it. Would this be only for some small examples? – egreg Jan 2 '13 at 18:09
@Mohan Perhaps a light grey background? – egreg Jan 2 '13 at 18:14
What about using other fonts? For example, sans serif math fonts or tt math fonts or even Euler fonts. – Sigur Jan 2 '13 at 18:52

A solution with hf-tikz (requires two compilation runs):

\documentclass[a4paper]{article}
\usepackage{framed}
\usepackage[customcolors]{hf-tikz}
\hfsetbordercolor{white}
\definecolor{vlgray}{rgb}{0.87 0.87 0.87}

\newcounter{highlight}
\newcommand{\highlight}[1]{%
\stepcounter{highlight}\tikzmarkin{\thehighlight}(0.04,-0.1)(-0.04,0.3)#1\tikzmarkend{\thehighlight}%
}

\newcommand{\exampletext}{%
If \highlight{$K \leq G$} and there are inclusions \highlight{$gKg^{-1}\leq K$}
for every \highlight{$g\in G$}, then \highlight{$K \triangleleft G$}: replacing
\highlight{$g$} by \highlight{$g^{-1}$}, we have the inclusion
\highlight{$g^{-1}Kg\leq K$}, and this gives the reverse inclusion
\highlight{$K\leq gKg^{-1}$}.

The kernel \highlight{$K$} of a homomorphism \highlight{$f:G\rightarrow H$} is a
normal  subgroup: if \highlight{$a\in K$}, then \highlight{$f(a)=1$}; if
\highlight{$g\in G$}, then
\highlight{$f(gag^{-1}) = f(g)f(a)f(g^{-1}) =$}\penalty\relpenalty
\highlight{$f(g)f(g^{-1}) = 1$},
and so \highlight{$gag^{-1}\in K$}. Hence, \highlight{$gKg^{-1}\leq K$} for all
\highlight{$g\in G$}, and so \highlight{$K \triangleleft G$}. Conversely,
we shall see later that every normal subgroup is the kernel of some homomorphism.}

\begin{document}
\hfsetfillcolor{white}
\begin{framed}
\exampletext
\end{framed}

\hfsetfillcolor{vlgray}
\begin{framed}
\exampletext
\end{framed}

Lorem ipsum \highlight{dolor} sit amet, \highlight{consectetuer} adipiscing elit, sed diam

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam

\end{document}


The result:

-
The second use is a bit inappropriate, thus I didn't answered directly to that question. – Claudio Fiandrino Jan 4 '13 at 8:41

Without using color for the formulas or a gray background, I don't see any good way for distinguishing between text and formulas. Boxing the formulas seems out of the question because it's really too heavy; underlining is, as you say, horrible.

A way out might be to present the same paragraphs typeset twice: one with blanks in place of the formulas, so by comparing the two images one can see what you're referring to.

\documentclass{article}
\usepackage{framed,calc}

\newcommand{\exampletext}{%
If \marksymbolic{$K \leq G$} and there are inclusions \marksymbolic{$gKg^{-1}\leq K$}
for every \marksymbolic{$g\in G$}, then \marksymbolic{$K \triangleleft G$}: replacing
\marksymbolic{$g$} by \marksymbolic{$g^{-1}$}, we have the inclusion
\marksymbolic{$g^{-1}Kg\leq K$}, and this gives the reverse inclusion
\marksymbolic{$K\leq gKg^{-1}$}.

The kernel \marksymbolic{$K$} of a homomorphism \marksymbolic{$f:G\rightarrow H$} is a
normal  subgroup: if \marksymbolic{$a\in K$}, then \marksymbolic{$f(a)=1$}; if
\marksymbolic{$g\in G$}, then
\marksymbolic{$f(gag^{-1}) = f(g)f(a)f(g^{-1}) =$}\penalty\relpenalty
\marksymbolic{$f(g)f(g^{-1}) = 1$},
and so \marksymbolic{$gag^{-1}\in K$}. Hence, \marksymbolic{$gKg^{-1}\leq K$} for all
\marksymbolic{$g\in G$}, and so \marksymbolic{$K \triangleleft G$}. Conversely,
we shall see later that every normal subgroup is the kernel of some homomorphism.}

\begin{document}
\begin{framed}
\providecommand{\marksymbolic}[1]{\makebox[\widthof{#1}]{\hrulefill}}
\exampletext
\end{framed}

\begin{framed}
\providecommand{\marksymbolic}[1]{\mbox{#1}}
\exampletext
\end{framed}

\end{document}


Here is the same with

\providecommand{\marksymbolic}[1]{{\fboxsep=0pt\colorbox[gray]{0.9}{#1}}}


-
In case anyone else tries this: the reducedstrut from tex.stackexchange.com/questions/74459/… makes the the height of the great boxes a little more consistent. – Mohan Jan 3 '13 at 18:04

The advise of "not to use greyscale" probably can be extended to the background, and personally I think so many gray boxes breaks the reading flow.

My proposal is use a clearly different fonts for the math and text modes, if needed, adjusting the size of math mode to look similar to text mode. Although one might think a higher size would highlight also the math mode, may be is only less readable. For example, for me with lxfonts look better a smaller font size:

\documentclass{article}
\usepackage{lxfonts}
\usepackage{framed}
\newcommand{\marksymbolic}[1]{{\footnotesize #1}}
\begin{document}
\usefont{T1}{lmr}{m}{n}
\begin{framed}
If
\marksymbolic{$K \leq G$} and there are inclusions
\marksymbolic{$gKg^{-1}\leq K$} for every
\marksymbolic{$g\in G$}, then
\marksymbolic{$K \triangleleft G$}: replacing
\marksymbolic{$g$} by
\marksymbolic{$g^{-1}$}, we have the inclusion
\marksymbolic{$g^{-1}Kg\leq K$}, and this gives the reverse inclusion
\marksymbolic{$K\leq gKg^{-1}$}.

The kernel
\marksymbolic{$K$} of a homomorphism
\marksymbolic{$f:G\rightarrow H$} is a normal subgroup: if
\marksymbolic{$a\in K$}, then
\marksymbolic{$f(a)=1$}; if
\marksymbolic{$g\in G$}, then
\marksymbolic{$f(gag^{-1}) = f(g)f(a)f(g^{-1}) = f(g)f(g^{-1}) = 1$}, and so
\marksymbolic{$gag^{-1}\in K$}. Hence,
\marksymbolic{$gKg^{-1}\leq K$}  for all
\marksymbolic{$g\in G$}, and so
\marksymbolic{$K \triangleleft G$}.
Conversely, we shall see later that every normal subgroup is the kernel of some homomorphism.
\end{framed}
\end{document}

-
from your code I can not obtain result as you show in your answer. Ordinary text is in the same, upright fonts as math expression. Please, can you check again if something is missing in your code? – Zarko Jun 17 '15 at 11:51
@Zarko, I am sure that the former code worked in 2011, but for some reason is not longer true. I changed the approach to use lxfonts only for math mode, but I cleaned also the unnecessary macros and brackets of the MWE in the question, but the result is the same as showed the image. – Fran Jun 17 '15 at 14:28
Dear @Fran, now work as advertised :-). And markup now is simpler! Eh, in three yeaers also in LaTeX many things changed. Thank you very much. – Zarko Jun 17 '15 at 14:45