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.

How to change the vertical position of a sidecap figure w.r.t. its top aligned caption? I want the caption to be right from the figure but align like in the attached mockup.

\documentclass{article}

\usepackage[demo]{graphicx}

\usepackage{sidecap}
\sidecaptionvpos{figure}{t}

\begin{document}

\begin{SCfigure}
    \includegraphics{graphs/dataset17b.pdf}
  \caption{Foo bar}
\end{SCfigure}

\end{document}

enter image description here

verbatimbox's addvbuffer fails for long captions:

addvbuffer

\documentclass{article}
\usepackage{verbatimbox}
\usepackage[demo]{graphicx}

\usepackage{sidecap}
\sidecaptionvpos{figure}{t}

\begin{document}

\begin{SCfigure}
    \includegraphics{graphs/dataset17b.pdf}
    \caption{\addvbuffer[5ex 0ex]{Foo bar}}
\end{SCfigure}

\begin{SCfigure}
    \includegraphics{graphs/dataset17b.pdf}
    \caption{\addvbuffer[5ex 0ex]{Foo bar Foo bar Foo bar Foo bar Foo
        bar Foo bar Foo bar Foo bar Foo bar}}
\end{SCfigure}

\end{document}
share|improve this question
    
Please, add some information about your problem. The example is surely not enough to do anything that shots in the dark: how do you produce the text above the image? –  egreg May 13 '13 at 12:21
add comment

2 Answers

up vote 0 down vote accepted
+100

EDIT: Solution revised to handle long captions. Place a vertical rule at the beginning of the caption:

\documentclass{article}
\usepackage[demo]{graphicx}

\usepackage{sidecap}
\sidecaptionvpos{figure}{t}

\begin{document}

\begin{SCfigure}
    \includegraphics{graphs/dataset17b.pdf}
    \caption{\protect\rule{0ex}{5ex}Foo bar Foo bar Foo bar Foo bar Foo bar Foo bar Foo bar }
\end{SCfigure}

\end{document}

enter image description here

share|improve this answer
    
Thanks. Unfortunately it fails for long captions. I added a picture and code to the original question. –  Somebody May 14 '13 at 9:06
    
The revised solution does not need verbatimbox anymore, does it? –  Somebody May 14 '13 at 12:38
    
@user1350789 Correct. I will remove it. –  Steven B. Segletes May 14 '13 at 12:51
add comment

Put the includegraphics in a minipage of matching width and insert an negative vspace.

\documentclass{article}

\usepackage[demo]{graphicx}

\usepackage{sidecap}
\sidecaptionvpos{figure}{t}

\begin{document}

\begin{SCfigure}
  \begin{minipage}{0.5\linewidth}
    \vspace{-\baselineskip}
    \includegraphics{graphs/dataset17b.pdf}
  \end{minipage}
  \caption{Foo bar}
\end{SCfigure}

\end{document}

Or use trim without clip in the includegraphics.

share|improve this answer
    
Hmmm.... this shouldn't be done; it can produce undesired results with the surrounding text: see the result of this simple example using your code: \documentclass{article} \usepackage[demo]{graphicx} \usepackage{sidecap} \sidecaptionvpos{figure}{t} \begin{document} aaaaaaaaaaaa aaaaaaaaaaaa aaaaaaaaaaaa aaaaaaaaaaaa aaaaaaaaaaaa \begin{SCfigure}[][!ht] \begin{minipage}{0.5\linewidth} \vspace{-\baselineskip} \includegraphics{graphs/dataset17b.pdf} \end{minipage} \caption{Foo bar} \end{SCfigure} aaaaaaaaaaaa aaaaaaaaaaaa aaaaaaaaaaaa aaaaaaaaaaaa aaaaaaaaaaaa \end{document} –  Gonzalo Medina May 9 '13 at 18:16
    
@GonzaloMedina I agree. Any idea how to do better? –  Somebody May 9 '13 at 18:42
    
Exactly which is the desired alignment? –  Gonzalo Medina May 9 '13 at 18:44
    
I have a figure with a rule on the top but also some text above. I want to do align the caption text with the rule leaving the text in the figure a bit higher. –  Somebody May 10 '13 at 6:47
    
Please edit your question and add an example of the actual code you are using, showing how you are producing the rule. –  Gonzalo Medina May 10 '13 at 12:49
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.