Hey,
i use \fbox{} inside a \caption{} and without \usepackage{subfig} everything works just fine. since i want to use subfigures i get an error:
! Argument of \@tempa has an extra } \caption{test \fbox{test}}
any suggestions? minimal working example:
_____________________________
\documentclass[12pt]{book}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{tikz}
\begin{document}
\begin{figure}[!ht]
\tikz{\node at (0,0) {TEST};}
\caption{test \fbox{test}}
\label{fig:test}
\end{figure}
\end{document}
Graphics, Figures & Tables ⇒ How to use \fbox in a \caption with the subfig-package
NEW: TikZ book now 40% off at Amazon.com for a short time.

Re: How to use \fbox in a \caption with the subfig-package
Hey guys,
i didn't find a solution in ohter fora and wonder if you get the same error?
i hope the tikz line doesn't prevent the code to be treated as a mwe
i didn't find a solution in ohter fora and wonder if you get the same error?
i hope the tikz line doesn't prevent the code to be treated as a mwe

How to use \fbox in a \caption with the subfig-package
Good things come to those who wait...
The problem comes along with \caption[]{}. Including the subfig-packages and a missing first parameter in the caption command won't work! why ever?
______________________________________________________________________________________
[1] works
______________________________________________________________________________________
[2] works not
______________________________________________________________________________________
[3] works
______________________________________________________________________________________
[4] works
______________________________________________________________________________________
The problem comes along with \caption[]{}. Including the subfig-packages and a missing first parameter in the caption command won't work! why ever?
______________________________________________________________________________________
[1] works
Code: Select all
Code, edit and compile here:
\documentclass[12pt]{book}%\usepackage{subfig} % comment out\usepackage{tikz}\begin{document}\begin{figure}[!ht]\tikz{\node at (0,0) {TEST};}\caption{test \fbox{test}} % here: \caption[missing]{}\label{fig:test}\end{figure}\end{document}
[2] works not
Code: Select all
Code, edit and compile here:
\documentclass[12pt]{book}\usepackage{subfig}\usepackage{tikz}\begin{document}\begin{figure}[!ht]\tikz{\node at (0,0) {TEST};}\caption{test \fbox{test}} % here: \caption[missing]{}\label{fig:test}\end{figure}\end{document}
[3] works
Code: Select all
Code, edit and compile here:
\documentclass[12pt]{book}\usepackage{subfig}\usepackage{tikz}\begin{document}\begin{figure}[!ht]\tikz{\node at (0,0) {TEST};}\caption{test} % here: \caption[missing]{}, no \fbox{}\label{fig:test}\end{figure}\end{document}
[4] works
Code: Select all
Code, edit and compile here:
\documentclass[12pt]{book}\usepackage{subfig}\usepackage{tikz}\begin{document}\begin{figure}[!ht]\tikz{\node at (0,0) {TEST};}\caption[solution]{test \fbox{test}} % here: \caption[not missing]{}\label{fig:test}\end{figure}\end{document}