Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Consider the following example:

\documentclass[11pt]{paper}
\usepackage[usenames]{color}

\definecolor{foo}{rgb}{0.75,0.0,0.0}
\everymath{\color{foo}}

\title{something}
\author{someone}
\begin{document}
\maketitle
this is some math: $a^2$. 
\end{document}

The math is colored red as intended. However, the author list is also colored. If I comment out the \everymath command, then both the author and the math change back to black.

I understand the function of \everymath, but I didn't realize that it affects author specification as well. Is this a known feature ?

share|improve this question
    
There are two answers to this question: yes, and no (it's known; it's not known). I find it hard to believe any of these would satisfy your need to learn about LaTeX:-). What more is it you want to know? –  Marc van Dongen Feb 28 '13 at 5:01
1  
the real question is: if it's a known feature, can it be disabled so I can color one without the other ? and also, why on earth would it be a feature as opposed to some mysterious interaction in the packages I'm using. –  Suresh Feb 28 '13 at 5:47
    
I believe that there is a solution, if you forget about $...$ and $$...$$ syntax and switch to \(...\) and \[...\] instead. If that it an option, please let us know ;) –  tohecz Feb 28 '13 at 8:42
5  
Yes, it's a known feature; many parts of LaTeX use math mode. For example, tabular, minipage and \parbox all use math mode and their output would be red (printing the author name is done with a tabular). So \everymath is not a good way to make all math red. –  egreg Feb 28 '13 at 9:34
    
I see. thanks a lot. I'd be happy to accept this as an answer. –  Suresh Feb 28 '13 at 15:27

1 Answer 1

up vote 14 down vote accepted

The main answer to your question is that \everymath is not a LaTeX command, i.e., you shouldn't have gotten that from any LaTeX manual or instruction. It is a bit unfortunate that a lot of the TeX primitives are given names that are very nice and that for historical reasons most formats (including LaTeX) kept those names available (also from plain TeX extensions) even if they are not safe to use in context of a more complicated environment such as LaTeX.

The technical reason for the behavior is that TeX is missing a number of important building blocks or offers them only in a roundabout way. E.g., vertical centering is available as \vcenter which is only possible in math mode, so a lot of higher-level constructs use a "fake" math mode to achieve special effects like this, even though technically speaking no formula is being build at all.

Having said that, there may be a way to get around this problem (but this is at your own risk :-)

Try

\makeatletter  \def\m@th{\mathsurround\z@\color{black}} \makeatother

in addition to your code. The reason why this most likely works, is that any "fake" math should include \m@th to cancel the extra space that could be added around formulas. So if all constructs in all packages are properly built, then this should do the trick.

share|improve this answer
2  
The LaTeX have spoken!!! :-) –  tohecz Feb 28 '13 at 16:13
    
@Frank Well, you can do vertical centring without math mode, but when LaTeX was written the overhead was too big :-) I guess we'll use the coffin mechanism for this in L3: no math mode needed, no strange effects! –  Joseph Wright Feb 28 '13 at 17:15
    
@JosephWright of course you can, but it was simply an example and yes there is some history about it as well. In fact, even for 2e we thought about providing \fake@math to better support the distinction, but given the huge amount of existing code it would have be fairly fruitless back then. Anyway, there are other cases, like \LaTeXe ... again could be solved differently but :-) ... nevertheless on the whole I guess \m@th will do the trick nicely enough –  Frank Mittelbach Feb 28 '13 at 17:21
    
No math mode in L3 ? –  Suresh Mar 1 '13 at 12:14
    
@Suresh so far expl3 is largely concerned with programming support while something like this would fall under what I would call "typesetting support". But yes, once we cant that done, I would expect constructs that either not "misuse math" or if they need to ensure that it is properly hidden, so that examples like yours wouldn't result in surprises. –  Frank Mittelbach Mar 1 '13 at 13:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.