TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For small figures, I want for captions to go on the right or on the left depending on the page number, whether it is odd or even. To do that I define the command \row as follows:

        #2 \hfil #1
        #1 \hfil #2

Typically, it is used inside the figure environment, for example,

    \caption{The transition temperature vs. density of the hydrogen} 

This works as desired in most cases, however, sometimes, placement of the caption goes wrong. I wonder why? And how to modify my code to avoid troubles?

share|improve this question
Please be a bit more specific about the circumstances under which "placement of the caption goes wrong." E.g., does it happen if there are multiple floats on a page? Does it only happen on verso (even-numbered) or on recto (odd-numbered) pages? – Mico Apr 27 '12 at 13:30
@Igor I wrote a solution for this at tex.stackexchange.com/a/45855/963 – Yiannis Lazarides Apr 27 '12 at 18:54
@Mico: unfortunetly I cannot at the moment specify condition when my code fails. – Igor Kotelnikov Apr 28 '12 at 7:13
up vote 11 down vote accepted

You can use the refcount package:

    #2 \hfil #1%
    #1 \hfil #2%

However you could also consider the sidecap package that does what you want without a special syntax (apart using SCfigure instead of figure).

share|improve this answer
Every answers given above are good. I have accepted this one because refcount package was already installed on my computer :) and because actually I expected something like this: set a label, convert \pageref to a number an so on. – Igor Kotelnikov Apr 28 '12 at 8:20

Due to the asynchronous nature of the output routine, the page counter isn't reliable. Use, e.g., the scrextend package and its \ifthispageodd macro instead.

share|improve this answer

Your Answer


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.