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 am using the \overset and \underset commands in ConTeXt, to place text over other text within a paragraph, e.g.:

(animal)                (animal)   (animal)
 Bears   like to   eat    fish  and snakes.
                (action)

The \overset command successfully places text above, but it also creates spaces in the main text, as shown above. I would prefer it the main text has normal spacing when possible, e.g.:

(animal)         (animal)   (animal)
 Bears like to eat fish and rabbits.
            (action)

Only in situations where two \oversets or \undersets appears next to each other and require more space than the regular text should extra spacing be added, e.g.:

(animal) (animal)   (animal)
 Bears,    fish, and frogs  eat,    play, and swim in the river.
                         (action) (action)  (action)
  • How can I condense the spacing around text when \oversets and \undersets are used, to the extent that is possible?
share|improve this question
1  
This question might be interesting for you. –  percusse Apr 4 '12 at 8:50
    
You can play with \llap, though it's not a solution, just a workaround. –  Marco Apr 4 '12 at 10:06
    
@Marco: why not define \clap? I wrote a short answer with this idea. –  mbork Apr 4 '12 at 10:42
    
You can also look at the ruby module by Wolfgang Schuster. –  Aditya Apr 4 '12 at 21:16
add comment

2 Answers

Here's a plain TeX solution (which, as Aditya mentioned, is already implemented in ConTeXt, even in a better, math-mode-compliant way)::

\def\clap#1{\hbox to 0pt{\hss #1\hss}}

Now \clap{whatever} sets whatever as if it had zero width, centered horizontally around the point it was encountered by TeX.

(Obviously, this macro follows the idea of \llap and \rlap.)

Of course this won't help when oversets etc. overlap.

Edit: as Marco pointed out in the comment, this might be better idea:

\def\clap#1{\hbox to 0pt{\hss\strut #1\hss}}

The \strut macro makes the \clap box as high (and deep) as the "highest/deepest" character in the font (at least in theory - but unless the settings are very weird, this should work).

share|improve this answer
3  
IMO it makes sense to include a \strut, otherwise the overtext almost always appears too close to the main text. –  Marco Apr 4 '12 at 10:53
    
@Marco: good point, I've included it in my answer. –  mbork Apr 4 '12 at 14:50
    
ConTeXt already has a \clap command (that works correctly both in text and math mode). –  Aditya Apr 4 '12 at 21:13
    
@Aditya: oops, I didn't know that. I've updated my answer. –  mbork Apr 5 '12 at 6:10
add comment

The simplest solution is to use a zero-with box \makebox[0pt]{} around the text you want either under or over. e.g.,

\overset{\makebox[0pt]{(\scriptsize animal)}}{Bears} 
share|improve this answer
6  
Welcome to TeX.SX! The question is about ConTeXt, which hasn't \makebox. –  egreg Oct 21 '13 at 9:30
add comment

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.