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.

Some time we write a=b\qquad -c=-d

then the negative sign was treated as minus sign, you know what happened: the space arround the sign is incorrect.

Although it can be done with {-}c=-d or \mathord{-}c=-d, I think there might be an elegant solution.

share|improve this question

2 Answers 2

It is not very difficult to use {-}. However, I seldom need to use a=b\qquad -c=-d in my document.

In fact, where you use a=b\qquad -c=-d, you may use:

$a=b$, $-c=-d$

or

\begin{align*}
a&=b & -c&=-d
\end{align*}
share|improve this answer

The problem is that \qquad isn't taken into account for the math spacing, so it's as if you typed a=b-c=-d. To automatically solve this problem, you can redefine \quad and \qquad by adding a \mathclose{} before them and a \mathopen{} after. To make them still usable in text mode, you need to test math mode with \ifmmode, begining by the standard \relax in that case:

effect of the new quad and qquad macros

\documentclass{article}
\usepackage{amsmath}
\renewcommand{\quad}{\relax\ifmmode\mathclose{}\fi
                     \hskip 1em\relax
                     \ifmmode\mathopen{}\fi}
\renewcommand{\qquad}{\relax\ifmmode\mathclose{}\fi
                      \hskip 2em\relax
                      \ifmmode\mathopen{}\fi}
\begin{document}
\[a=b{,}\qquad -c=-d.\]
or
\[a=b \quad \text{and} \quad -c=-d.\]
\end{document}
share|improve this answer
    
Are there too many \relax's? I can't see any advantage to using \relax. –  Leo Liu Jan 28 '11 at 16:26
1  
@Leo Liu: The \relax before \ifmmode is to ward against the side effect mentioned in the TeXbook, page 240 (relative to when TeX is looking for an \omit in an \halign); it is nearly systematically used in the LaTeX kernel. The \relax after \hskip is to avoid \quad plus (in text mode) to think the plus is the sequel of 1em as in \hskip 1em plus 3pt. –  Philippe Goutet Jan 28 '11 at 16:46
    
thanks for your comments. –  Leo Liu Jan 28 '11 at 19:06

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.