How can I display text to the right of figure, vertically centered? "Caption" is only displaying text below it, as it seems to me.
[Tex/LaTex] Put text to the right of figures
captionsfloatsnumbering
Related Solutions
Since the default behaviour is to typeset the caption text and numbering together, rather than break them apart, your hack works. It may just seem awkward since you're using \caption
without actually giving a caption.
To that end, you could define "more convenient" commands that would do the same:
\documentclass{article}
\usepackage[demo]{graphicx}% http://ctan.org/pkg/graphicx
\usepackage{caption}% http://ctan.org/pkg/caption
\captionsetup{labelsep=none,textfont=it}% Format caption settings
\newcommand{\floattitle}[1]{%
\def\floattitletext{#1}% Store float title text
\captiontextfont\strut #1\par\vskip\abovecaptionskip}
\newcommand{\floatnumber}{\caption[\floattitletext]{}}
\begin{document}
\begin{figure}
\centering
\floattitle{Descriptive title string goes here}
\includegraphics[width=0.7\linewidth]{image}
\floatnumber \label{monitor-main-window}
\end{figure}
\end{document}
The above example uses the caption
package to format the float captions via key-value pairs. As such, you can use these key-values to format the separate components of the caption. I've defined \floattitle{<title>}
which typesets the float title using \captiontextfont
(it also stores <title>
for later use). It also adds a gap at below the caption that is equivalent to the gap above the "actual caption" below the image. Also \floatnumber
is a duplicate of \caption{}
, which typesets nothing, but adds the correct reference test so you're able to use \listoffigures
and/or \listoftables
. Note that the command names are general, so you can use them in either a figure
or a table
environment.
Finally, for correct referencing, you need to place the \label
after \floatnumber
(or \caption
in general). See Where to put the \label on a figure environment?
graphicx
with the demo
option was used to be able to typeset an image image
without it actually being there - replacing it by a 150pt x 100pt rectangle. Don't use the demo
option otherwise.
As announced in my comment above here comes a MWE which uses the option calcmargin=
of the caption
package to setup a right margin which hopefully fits your specification:
\documentclass{article}
\usepackage{calc}
\usepackage[figurename=Fig.]{caption}
\DeclareCaptionStyle{figstyle}
[format=plain,margin=0pt,justification=centering]
{format=hang,calcmargin={0pt,\widthof{\captionfont\captionlabelfont\figurename~\thefigure: }},
font=small,labelfont=bf}
\captionsetup[figure]{style=figstyle}
\begin{document}
\begin{figure}
\hrulefill
\caption{Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\ldots}
\hrulefill
\end{figure}
\begin{figure}
\hrulefill
\caption{Blah blah blah blah blah blah blah blah blah blah blah\ldots}
\hrulefill
\end{figure}
\end{document}
The syntax of the calcmargin=
option is the same as margin=
but its value will not be set immediately but calculated for every individual caption instead. (Unfortunately calcmargin=
isn't documented yet.)
For example, the same is possible for tables with the same format:
\DeclareCaptionStyle{tabstyle}
[format=plain,margin=0pt,justification=centering]
{format=hang,calcmargin={0pt,\widthof{\captionfont\captionlabelfont\tablename~\thetable: }},
font=small,labelfont=bf}
\captionsetup[table]{style=tabstyle}
and for subfigures in the format of (a)
, (b)
, etc. using the subcaption
package
\DeclareCaptionStyle{subfigstyle}
[format=plain,margin=0pt,justification=centering]
{format=hang,calcmargin={0pt,\widthof{\captionfont\captionlabelfont(\thesubfigure) }},
font=small,labelfont=bf}
\captionsetup[subfigure]{style=subfigstyle}
Update: My first example code was crap, hopefully this one is better.
Update 2 (by riddleculous): added the same for tables and subcaptions
Best Answer
You can use the sidecap package and the
c
(centered) option for\sidecaptionvpos
:If the captions should always appear to the right, you can use the
rightcaption
package option:Another option, using
\capbeside
, from the powerfulfloatrow
package this time:The
demo
option forgraphicx
simply replaces actual figures with black rectangles; do not use that option in your actual document.