6

I face a similiar problem like the one described here. I created a command that will output a caption besides an image (in this example replaced by simple text).

\documentclass[a4paper,12pt]{scrartcl} 
\usepackage[ngerman]{babel}    
\usepackage[T1]{fontenc}       
\usepackage[utf8]{inputenc} 
\usepackage{graphicx}
\usepackage{vwcol}  
\usepackage{caption}

\captionsetup{format=plain,width=0.7\textwidth}

\begin{document}
\newcommand{\yasfig}[3]
{\begin{vwcol}[widths={0.3,0.7},
 sep=.8cm, justify=flush,rule=0pt,indent=0em]
#1

\begin{minipage}{0.68\linewidth}
\captionof{figure}{#2}
\label{#3}
\end{minipage}
\end{vwcol}}

\yasfig{Gel}{Bla}{fig:Gel}
\yasfig{Blot}{Bla}{fig:Blot}

\end{document}

This will output the desired layout but increase the figure count by 2 each time the command is called. I'm guessing it has something to do with the minipage but I'm at a loss here.

1

If all you need to do is to place the caption beside the image, then there are other ways than using a multi-column environment, such as using two minipages next to one another, the first with the image, the second with the caption. Another way is to use the captionofbeside environment provided by the KOMA classes.

Note that I don't know exactly how wide you wanted the images and caption, so you may want to modify the widths. The minipage in the captionofbeside environment isn't strictly necessary. Some modifications may also be necessary with regard to the vertical alignment of caption and image, but I don't know exactly how you want that.

\documentclass[a4paper,12pt]{scrartcl} 
\usepackage[ngerman]{babel}    
\usepackage[T1]{fontenc}       
\usepackage[utf8]{inputenc} 
\usepackage{graphicx}
\usepackage{caption}

\captionsetup{format=plain,width=0.7\textwidth}

\newcommand{\yasfig}[3]
{\noindent\begin{minipage}{0.25\linewidth}
#1
\end{minipage}\hfill
\begin{minipage}{0.68\linewidth}
\captionof{figure}{#2}
\label{#3}
\end{minipage}}

\newcommand\yyasfig[3]{%
\noindent\begin{captionofbeside}{figure}{#2\label{#3}}[r]
\begin{minipage}{.25\linewidth}
#1
\end{minipage}
\end{captionofbeside}}
\begin{document}

\yasfig{\includegraphics[width=\linewidth,height=2cm]{example-image}}{Bla}{fig:Gel}
\yasfig{\includegraphics[width=\linewidth,height=2cm]{example-image-a}}{Bla}{fig:Blot}

\yyasfig{\includegraphics[width=\linewidth,height=2cm]{example-image-b}}{Bla}{fig:Gel2}
\yyasfig{\includegraphics[width=\linewidth,height=2cm]{example-image-c}}{Bla}{fig:Blot2}

\end{document}
| improve this answer | |
1

Not sure why it fixes it, but I subtract 1 from the figure counter before leaving vwcol, and then add it back in after leaving the environment. Something to do with vwcol, I presume, or else as you suspect, and interaction of vwcol and minipage.

\documentclass[a4paper,12pt]{scrartcl} 
\usepackage[ngerman]{babel}    
\usepackage[T1]{fontenc}       
\usepackage[utf8]{inputenc} 
\usepackage{graphicx}
\usepackage{vwcol}  
\usepackage{caption}

\captionsetup{format=plain,width=0.7\textwidth}

\begin{document}
\newcommand{\yasfig}[3]
{\begin{vwcol}[widths={0.3,0.7},
 sep=.8cm, justify=flush,rule=0pt,indent=0em]
#1

\begin{minipage}{0.68\linewidth}
\captionof{figure}{#2}
\label{#3}
\end{minipage}
\addtocounter{figure}{-1}%
\end{vwcol}\addtocounter{figure}{1}%
}

\yasfig{Gel}{Bla}{fig:Gel}
\yasfig{Blot}{Bla}{fig:Blot}

\end{document}

enter image description here

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