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.

I have the product of two quantities with diacritics (\tilde, \hat and \bar - to be more precise), which give this ugly result. Based on your PDF viewer and zoom selection the sight might be more or less of an eyesore.

The other problem is the height at which the diacritics appear above the lowercase v, which is horrble when the d is next to it.

How can I fix these things? Is there any kind of panacea for all these problems?

Here's the code for a few samples:

\documentclass[10pt,a4paper,oneside,reqno]{amsbook}

\usepackage{pxfonts}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}

\begin{document}

\begin{equation}
    \begin{split}
        \tilde{d}\kern1pt\tilde{i}_c\\
        \tilde{d}\tilde{v}_{ap}
    \end{split}
\end{equation}

\begin{equation}
    \begin{split}
        \hat{d}\hat{i}_c\\
        \hat{d}\hat{v}_{ap}
    \end{split}
\end{equation}

\begin{equation}
    \begin{split}
        \bar{d}\bar{i}_c\\
        \bar{d}\bar{v}_{ap}
    \end{split}
\end{equation}

\end{document}

... and the result:

enter image description here

PS: Using an increased kerning between the factors of the products makes things bearable (i.e. avoids the tildes sticking together), but I think that's a really clumsy hack and I'd like to have a more elegant solution.

PS2: As per request, a sample of what I'd like to achieve (using Photoshop after LaTeX :P). Granted, the hat floats high above the v, but I prefer it that way. :)

enter image description here

share|improve this question
    
Good question, to which I don't have a good answer:-) the horizontal kerning is perhaps easier to automate, but what do you want to happen for hat d hat v If you make the hat always high enough to fit over a d it would look very high on a v, so I suspect there isn't much you can do about that even if you think it looks horrible. (If you think there is a more pleasing typesetting of that, post an image with it, even if you have just faked it by moving the diacritics in an image editor, then it gives anyone trying automated macros something to aim for. –  David Carlisle May 28 '12 at 12:42
    
@DavidCarlisle: Question updated to accommodate your request. :) –  Count Zero May 28 '12 at 12:54
    
It's well known that the PXfonts don't have good sidebearings for math characters. I'd suggest to use mathpazo instead. –  egreg May 28 '12 at 18:25
    
@egreg: Thanks for the suggestion, will switch over. –  Count Zero May 28 '12 at 18:49

2 Answers 2

up vote 3 down vote accepted

Here's a solution to the d/v-problem that automatically inserts the correct kerns for the accent. The idea is taken from another answer of mine, which in turn is based on what I learned from TH. The command \ra ("raise accent") takes two arguments, the accent and the letter. The accent is then put at the same height as it would be over the letter d. This works equally well for normal text and for sub-/superscripts:

example with accents

The solution also works if you replace pxfonts with mathpazo – I strongly support this suggestion of egreg (see comment to the question). However, let me point out that this only works for latin letters, so \ra \hat \gamma won't work. Note that \ra \hat d has the same effect as \hat d since the accent doesn't have to be raised.

Personally, I wouldn't raise the accents; I think it's substituting one eyesore for another.

\documentclass{article}

\usepackage{pxfonts}

\makeatletter
\newcommand*\ra[2]{%
        \begingroup
        \mathchoice{\ra@helper{#1}{#2}{\displaystyle}{\textfont}}
                   {\ra@helper{#1}{#2}{\textstyle}{\textfont}}
                   {\ra@helper{#1}{#2}{\scriptstyle}{\scriptfont}}
                   {\ra@helper{#1}{#2}{\scriptscriptstyle}{\scriptscriptfont}}%
        \endgroup
        #2%
}
\newcommand*\ra@helper[4]{%
        \def\currentfont{\the#41}%
        \def\currentskewchar{\char\the\skewchar\currentfont}%
        \setbox\tw@\hbox{\currentfont#2\currentskewchar}%
        \dimen@ii\wd\tw@
        \setbox\tw@\hbox{\currentfont#2{}\currentskewchar}%
        \advance\dimen@ii-\wd\tw@
        \rlap{$\m@th#3\kern\dimen@ii#1{\vphantom{d}\phantom{#2}}$}%
}
\makeatother

\begin{document}
\Huge
$\ra\hat d\ra\hat v_{ap}$
$A_{\ra\hat d\ra\hat v_{ap}}$
\end{document}
share|improve this answer
    
Thanks for the nice solution, wrapping things into a macro, that's definitely a plus! In the meantime, egreg also pointed out in a comment the that mathpazo was a better choice than pxfonts. Nevertheless, the accents need to be arranged there, too... –  Count Zero May 31 '12 at 11:28
    
@Count: Ah, I didn't read egreg's comment properly. My solution works with mathpazo, too, and there the f is fine. –  Hendrik Vogt May 31 '12 at 11:36
    
Yep, it does! :) –  Count Zero May 31 '12 at 11:37

For the d/v hat perhaps

         \hat{d}\hat{v\vphantom{d}\,}\!_{ap}

does what you want:

enter image description here

It could perhaps be incorporated with a general macro that makes each accent macro look-ahead and insert horizontal kerns or vertical struts on a case-by-case basis.

share|improve this answer
1  
Seeing that makes me shiver. ;-) –  egreg May 28 '12 at 20:02

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.