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.

In question 83509, a way of getting \hfill-like behaviour in the align environment is described, but for my purposes, I need one that works in the equation environment. (I want to display some commutative diagrams next to each other, but for some reason, tikzcd does not like being inside align.)

  1. Why does TeX ignore \hfill inside displayed mathematics?
  2. How can this be worked around?

I suppose I could in principle just put the various blocks inside $...$, but for consistency, it would be probably be better to have all displayed mathematics in equation or similar environments.

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

You can force things to stretch by giving them a large natural width and allowing them to shrink, rather than \hfill which has a natural width of 0pt.

so

$$a\hskip \textwidth minus \textwidth b$$

produces

enter image description here

But a CD package is almost certainly making a box anyway so placing them inside a display math environment probably doesn't achieve much, however if you mean what I think you mean then putting shrinkable glue between two boxes will force them apart as shown here.

share|improve this answer
    
The tikzpicture environment (and by extension tikzcd) is, for some strange reason, typeset inline. I always enclose it in \[ ... \] to make sure it is displayed like other bits of maths. –  Zhen Lin Apr 29 '13 at 20:47
    
Your solution seems to meet the requirements, thanks! But I'm all the more puzzled: isn't \hfill also internally implemented as a kind of \hskip? –  Zhen Lin Apr 29 '13 at 20:50
1  
@ZhenLin \hfill is \hskip 0pt plus 1fill so it has a natural width of 0pt and just stretches if needed. the skip I used has a natural size of \textwidth and shrinks if needed. When setting a display math TeX is centering it internally so almost never needs to stretch glue so \hfill doesn't stretch,but it needs to shrink this glue so it shrinks by the minimum amount required to make the whole display fit so forces the items apart as far as possible. –  David Carlisle Apr 29 '13 at 20:58
    
@ZhenLin It's not strange, since one might be producing a very small image to appear inline. For example, as a special symbol. More abstractly, it keeps your options open, whereas there is no way to un-display something. –  Ryan Reich Apr 29 '13 at 21:50
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.