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 want to use the sidecaption environment in a figure with memoir and have the caption text be ragged against the text block. But when the figure is moved to the next page, the caption is on the correct side but the raggedness is wrong. I have created the following MWE according to the memoir manual but even with \strictpagecheck it does not work, no matter how many luatex runs I do:

\documentclass[a4paper,twoside,draft]{memoir}

\usepackage{fixltx2e}
\usepackage{calc}

\usepackage{luatextra}
\usepackage{lipsum}
\usepackage{ragged2e}


\marginparmargin{outer}
\setmpjustification{\RaggedLeft}{\RaggedRight}

% margin figure and caption typeset ragged against text block
\setfloatadjustment{marginfigure}{\mpjustification}
\setmarginfloatcaptionadjustment{figure}{\captionstyle{\mpjustification}}


\sidecapmargin{outer}
\setsidecappos{t}
\setsidecaps{\marginparsep}{\marginparwidth}



\setlength{\fboxsep}{0pt}

\begin{document}

\lipsum[1]
\begin{figure}[p]
    \strictpagecheck
    \begin{sidecaption}{This is an example text. It should be ragged on the page
                        border, not on the side of the figure.}
        \fbox{\parbox[t][\textheight - 4pt][c]{\linewidth - 3pt}{test}}
    \end{sidecaption}
\end{figure}
\lipsum

\end{document}
share|improve this question

2 Answers 2

up vote 3 down vote accepted

A simpler one, basically we just need to execute \m@mscapcheckside before the contents is stored inside a box

\makeatletter
\def\endsidecaption{%
  \m@mscapend@fbox
  \refstepcounter\@captype
  \m@mscaplabel
  \m@mscapcheckside %<---- added this
  \begin{lrbox}{\m@mscap@capbox}%
    \begin{minipage}[c]{\sidecapwidth}%
      \sidecapstyle
      \@caption\@captype[\m@mscap@fortoc]{\m@mscap@forcap}
    \end{minipage}%
  \end{lrbox}%
  \m@mscapopboxes}
\renewcommand*{\m@mscapopboxes}{%
  \m@mcalcscapraise
  \usebox{\m@mscap@fbox}%\m@mscapcheckside %<--- removed here
  \ifscapmargleft%
    \rlap{\kern-\m@mscaplkern
          \raisebox{\m@mscapraise}{\usebox{\m@mscap@capbox}}}%
  \else%
    \rlap{\kern\sidecapsep
          \raisebox{\m@mscapraise}{\usebox{\m@mscap@capbox}}}%
  \fi
  \gdef\m@mscapthisside{}%
  \@mem@scap@afterhook%
}
\makeatother
share|improve this answer

From Lars Madsen on comp.text.tex:

This seems to do the trick

\def\endsidecaption{%
   \m@mscapend@fbox
   \refstepcounter\@captype
   \m@mscaplabel
   \def\mem@evil{\begin{minipage}[c]{\sidecapwidth}%
       \sidecapstyle
       \@caption\@captype[\m@mscap@fortoc]{\m@mscap@forcap}
     \end{minipage}}%
   \begin{lrbox}{\m@mscap@capbox}%
     \mem@evil
   \end{lrbox}%
   \m@mscapopboxes}
\renewcommand*{\m@mscapopboxes}{%
   \m@mcalcscapraise
   \usebox{\m@mscap@fbox}\m@mscapcheckside
   \ifscapmargleft%
     \rlap{\kern-\m@mscaplkern
       \raisebox{\m@mscapraise}{\mem@evil}}%
   \else%
     \rlap{\kern\sidecapsep
           \raisebox{\m@mscapraise}{\mem@evil}}%
   \fi
   \gdef\m@mscapthisside{}%
   \@mem@scap@afterhook%
}

basically we need two things, we need to have the caption inside a box in order to do some measuring, and we need to make sure that the caption is actually typeset at the right momemnt.

share|improve this answer

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.