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?

  • 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

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).

| 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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.