TransWikia.com

vertical position of sidecap figure with respect to top aligned caption

TeX - LaTeX Asked by Somebody on February 11, 2021

How to change the vertical position of a sidecap figure with respect to 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}

3 Answers

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.5linewidth}
    vspace{-baselineskip}
    includegraphics{graphs/dataset17b.pdf}
  end{minipage}
  caption{Foo bar}
end{SCfigure}

end{document}

Or use trim without clip in the includegraphics.

Answered by Somebody on February 11, 2021

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{protectrule{0ex}{5ex}Foo bar Foo bar Foo bar Foo bar Foo bar Foo bar Foo bar }
end{SCfigure}

end{document}

enter image description here

Answered by Steven B. Segletes on February 11, 2021

Simply add the following to your preamble after loading the sidecap package:

sidecaptionvpos{figure}{t}

Or for center alignment:

sidecaptionvpos{figure}{c}

It's an undocumented feature.

Answered by dwitvliet on February 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP