[Tex/LaTex] How to make the figure float [H] here when I use SCfigure

floatsgraphics

When I was using \begin{figure}....\end{figure}, I was able to fix the figure in the location using the [H], [h], or [h!] options, but that doesn't work when I use SCfigure. How do I fix a SCfigure in place?

\documentclass[12 pt , twoside, a4paper] {article}
\usepackage[pdftex]{graphicx}
\usepackage{sidecap}
\begin{document}
\begin{SCfigure}
\includegraphics[scale=0.5]{EffectiveArea}
\caption{height of cylinder=v$\Delta$t  \newline
volume of cylinder=$\pi (2r)^2(v\Delta t)$  \newline
number of collision per second=$\frac{N}{V_{molecule}}V_{cylinder}
\newline \quad \quad \quad \quad =\frac{N}{V_{molecule}}\pi (2r)^2(v\Delta t)$}
\end{SCfigure}
\end{document}

And the error is: ! LaTeX Error: \caption outside float.

Best Answer

If you still want to use the old package sidecap, remember that the floating specifier is the second optional parameter of SCfigure, so you have to use it as, for example,

\begin{SCfigure}[][h]

if you want the h specifier.

Also sidecap seems not to be compatible with float, so the H specifier cannot be used.

MWE:

\documentclass[12 pt , twoside, a4paper] {article}
\usepackage[pdftex,demo]{graphicx}  %remove demo option in your document
\usepackage{sidecap}
\begin{document}
\begin{SCfigure}[][h]
\includegraphics[scale=0.5]{EffectiveArea}
\caption{height of cylinder=v$\Delta$t  \newline
volume of cylinder=$\pi (2r)^2(v\Delta t)$  \newline
number of collision per second=$\frac{N}{V_{molecule}}V_{cylinder}
\newline \quad \quad \quad \quad =\frac{N}{V_{molecule}}\pi (2r)^2(v\Delta t)$}
\end{SCfigure}
\end{document}

Output:

enter image description here

Otherwise you can switch to the floatrow package as mentioned in Bernard's comment and, issuing a command like

\floatsetup[figure]{capposition=beside,capbesideposition={top,right}}

you can obtain the same (probably better) result using the figure environment.

MWE:

\documentclass[12 pt , twoside, a4paper] {article}
\usepackage[pdftex,demo]{graphicx}  %remove demo option in your document
\usepackage{floatrow}
\floatsetup[figure]{capposition=beside,capbesideposition={top,right}}
\begin{document}
\begin{figure}[h]
\includegraphics[scale=0.5]{EffectiveArea}
\caption{height of cylinder=v$\Delta$t  \newline
volume of cylinder=$\pi (2r)^2(v\Delta t)$  \newline
number of collision per second=$\frac{N}{V_{molecule}}V_{cylinder}
\newline \quad \quad \quad \quad =\frac{N}{V_{molecule}}\pi (2r)^2(v\Delta t)$}
\end{figure}
\end{document} 

Output:

enter image description here