PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : subfig: \subref in \caption gibt Fehler



ElGato
03-12-2006, 14:09
Hallo ihr lieben,

habe mal wieder ein Problem mit meinem geliebten subfig Packet. Ich versuche es nun seit Stunden und bekomme dieses Problem nicht in Griff :(
Wenn ich in die caption einen Verweis mit subref setzte, bekomme ich Fehler. Wenn ich den gleichen Text außerhalb von caption mache, geht es ohne Probleme. Ich habe absolut keine Ahnung, was nicht stimmt und hoffe, das jemand mir helfen kann!

Hier das Minimalbeispiel:


\documentclass{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
% \usepackage[subfigure]{tocloft}
\usepackage[justification=justified,singlelinecheck=false,labe lfont={bf,small,sf},font={small,sf},
aboveskip=0.5em,belowskip=0em]{caption}
\usepackage[justification=justified,singlelinecheck=false,labe lfont={small,sf},font={small,sf}]{subfig}
% \setcounter{lofdepth}{3} % depth of the table of figures
\usepackage[english]{varioref}
\usepackage[pdfpagelabels=true,english,backref,pagebackref]{hyperref}
\hypersetup{colorlinks=true,breaklinks=true,linkco lor=blue,menucolor=blue,pagecolor=blue}
\usepackage[all]{hypcap} % a link jumps and focus on the picture and not on the caption

% Kombination of \autoref and \vref =>Figures/tables/chapters... together with nomber as a hyperlink in the pdf
\newcommand*{\fvref}[1]{\hyperref[#1]{\figurename}\vref{#1}}
\newcommand*{\tvref}[1]{\hyperref[#1]{\tablename}\vref{#1}}
\newcommand*{\chaptervref}[1]{\hyperref[#1]{\chapterautorefname}\vref{#1}}
\newcommand*{\sectionvref}[1]{\hyperref[#1]{\sectionautorefname}\vref{#1}}

\begin{document}

\def\figbox#1#2#3{%
\fbox{\hbox to #1{%
\vbox to #2{%
\vfil
\hbox to #1{%
\hfil
#3
\hfil}%
\vfil}}}}



\begin{figure}[htbp]
\subfloat[captionOfPic1InLof][]{\label{subfig:1}{\figbox{5cm}{5cm}{One}}}
\hfill
\subfloat[captionOfPic2InLof][]{\label{subfig:2}{\figbox{6cm}{4cm}{Two}}}
\caption{captionOfPic1And2 \subref{subfig:1} is here \subref{subfig:2} that's here}
\label{fig:1}
\end{figure}


% to get the list as an bookmark
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{\listfigurename}
\listoffigures

\end{document}

sofa-surfer
03-12-2006, 14:17
Hallo,

was du versuchen kannst, ist das optionale Argument der caption zu nutzen:
\caption[Kurztitel ohne Referenzen]{captionOfPic1And2 \subref{subfig:1} is here \subref{subfig:2} that's here}

oder vielleicht auch so was:
\caption{captionOfPic1And2 \protect\subref{subfig:1} is here \protect\subref{subfig:2} that's here}

Beides aber nicht getestet.

Matthias

ElGato
03-12-2006, 18:30
Hi Sofa-Surfer,

danke für den Versuch das \protect hat leider nicht geklappt :(
Das mit dem optinalen Argument habe ich leider nicht so verstanden, wie es zum Ziel führen sollte. Ich dachte hierbei ginge es nur um den Eintrag im (Abbildungs-) Verzeichnis.

Hoffe weiterhin, das mir jemand helfen kann. Irgenwie glaube ich, dass es mit den Argumenten aus dem subfig und caption Packet zusammen hängt, da \subref außerhalb von caption problemlos klappt. Aber vielleicht irre ich mich auch total.

Lieben Gruß

ElGato

sofa-surfer
03-12-2006, 19:04
Hallo,

also ich habs nun doch noch mal selbst versucht und beides funktioniert bei mir:


\documentclass{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
% \usepackage[subfigure]{tocloft}
\usepackage[justification=justified,singlelinecheck=false,labe lfont={bf,small,sf},font={small,sf},
aboveskip=0.5em,belowskip=0em]{caption}
\usepackage[justification=justified,singlelinecheck=false,labe lfont={small,sf},font={small,sf}]{subfig}
% \setcounter{lofdepth}{3} % depth of the table of figures
\usepackage[english]{varioref}
\usepackage[pdfpagelabels=true,english,backref,pagebackref]{hyperref}
\hypersetup{colorlinks=true,breaklinks=true,linkco lor=blue,menucolor=blue,pagecolor=blue}
\usepackage[all]{hypcap} % a link jumps and focus on the picture and not on the caption

% Kombination of \autoref and \vref =>Figures/tables/chapters... together with nomber as a hyperlink in the pdf
\newcommand*{\fvref}[1]{\hyperref[#1]{\figurename}\vref{#1}}
\newcommand*{\tvref}[1]{\hyperref[#1]{\tablename}\vref{#1}}
\newcommand*{\chaptervref}[1]{\hyperref[#1]{\chapterautorefname}\vref{#1}}
\newcommand*{\sectionvref}[1]{\hyperref[#1]{\sectionautorefname}\vref{#1}}

\begin{document}

\def\figbox#1#2#3{%
\fbox{\hbox to #1{%
\vbox to #2{%
\vfil
\hbox to #1{%
\hfil
#3
\hfil}%
\vfil}}}}



\begin{figure}[htbp]
\subfloat[captionOfPic1InLof][]{\label{subfig:1}{\figbox{5cm}{5cm}{One}}}
\hfill
\subfloat[captionOfPic2InLof][]{\label{subfig:2}{\figbox{6cm}{4cm}{Two}}}
\caption[captionOfPic1And2]{captionOfPic1And2 \subref{subfig:1} is here \subref{subfig:2} that's here}
\label{fig:1}
\end{figure}


\begin{figure}[htbp]
\subfloat[captionOfPic1InLof][]{\label{subfig:1}{\figbox{5cm}{5cm}{One}}}
\hfill
\subfloat[captionOfPic2InLof][]{\label{subfig:2}{\figbox{6cm}{4cm}{Two}}}
\caption{captionOfPic1And2 \protect\subref{subfig:1} is here \protect\subref{subfig:2} that's here}
\label{fig:2}
\end{figure}


% to get the list as an bookmark
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{\listfigurename}
\listoffigures

\end{document}

Matthias

ElGato
03-12-2006, 19:48
Hallo Sofa-Surfer,

tut mir echt leid, ich gebe Dir absolut Recht! War mein Fehler, hatte Probleme bei der Übertragung von meinem Minimalbeispiel auf mein Problem :(

Der Fehler lag hier:

\caption{captionOfPic1And2 \\ % <-- hier war das Problem, \newline ist hier richtig
\protect\subref{subfig:1} is here \protect\subref{subfig:2} that's here}

Nochmals vielen Dank für Deine Hilfe!!!

Lieben Gruß und schönen Tag
ElGato