我正在准备一篇俄语文本pdflatex
。根据标准,附录必须用俄语大写字母编号。
但我发现如果在附录中使用子浮点数,则hyperref
第二遍会产生错误pdflatex
。
! Undefined control sequence.
<argument> subfigure.\T
2A\CYRA .1.1
以下是重现错误的代码:
\documentclass[a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}
\usepackage[T2A]{fontenc}
\usepackage{graphicx}
\usepackage[config,font=small,labelsep=period]{caption,subfig}
\usepackage[unicode]{hyperref}
%use russian alphabet for subfigure counter
\makeatletter
\def\thesubfigure{\textit{\asbuk{subfigure}}}
\providecommand\thefigsubsep{,~}
\def\p@subfigure{\@nameuse{thefigure}\thefigsubsep}
\makeatother
\begin{document}
\chapter{Sample Chapter}
\appendix
%use russian alphabet for appendix counter
\makeatletter
\gdef\thechapter{\@Asbuk\c@chapter}
\makeatother
\chapter{Sample Appendix}
Reference \ref{fig_images}, also \ref{fig_image1} and \ref{fig_image2}.
\begin{figure}
\centering
\subfloat[][]{\label{fig_image1}\includegraphics[width=0.15\linewidth]{image1}}
\hspace{0.15\linewidth}
\subfloat[][]{\label{fig_image2}\includegraphics[width=0.15\linewidth]{image2}}
\caption[]{\label{fig_images}
Images:
\subref{fig_image1}~---~first;
\subref{fig_image2}~---~second;
}
\end{figure}
\end{document}
有什么解决方法可以让它工作吗?或者有其他的subfig
软件包吗?
答案1
已知该subfig
软件包存在问题hyperref
。您可以subcaption
尝试使用我的软件包:
\documentclass[a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}
\usepackage[T2A]{fontenc}
\usepackage[demo]{graphicx}
\usepackage[config,font=small,labelsep=period]{caption}
\usepackage{subcaption}
\usepackage[unicode]{hyperref}
%use russian alphabet for subfigure counter
\makeatletter
\def\thesubfigure{\textit{\asbuk{subfigure}}}
\providecommand\thefigsubsep{,~}
\def\p@subfigure{\@nameuse{thefigure}\thefigsubsep}
\makeatother
\begin{document}
\chapter{Sample Chapter}
\appendix
%use russian alphabet for appendix counter
\makeatletter
\gdef\thechapter{\@Asbuk\c@chapter}
\makeatother
\chapter{Sample Appendix}
Reference \ref{fig_images}, also \ref{fig_image1} and \ref{fig_image2}.
\begin{figure}
\centering
\subcaptionbox{\label{fig_image1}}{\includegraphics[width=0.15\linewidth]{image1}}
\hspace{0.15\linewidth}
\subcaptionbox{\label{fig_image2}}{\includegraphics[width=0.15\linewidth]{image2}}
\caption[]{\label{fig_images}
Images:
\subref{fig_image1}~---~first;
\subref{fig_image2}~---~second;
}
\end{figure}
\end{document}
(我很抱歉这样无耻地自我宣传,但 subfig 与 hyperref 的问题是我编写 subcaption 包的众多原因之一。)
附录:
与 subfig 包相反,subcaption 包将仅将\thesubfigure
resp.的值\thesubtable
作为引用输出,因为这也是所有其他引用的行为,例如对图或章节的引用。因此,如果想要在引用中使用括号(或其他装饰元素),则必须将它们添加到那里并从标签格式中删除(这样它们就不会在那里出现两次),例如使用选项labelformat=simple
。例如:
\documentclass[a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}
\usepackage[T2A]{fontenc}
\usepackage[demo]{graphicx}
\usepackage[config,font=small,labelsep=period]{caption}
\usepackage[labelformat=simple]{subcaption}
\usepackage[unicode]{hyperref}
%use russian alphabet for subfigure counter
\makeatletter
\def\thesubfigure{(\textit{\asbuk{subfigure}})}
\providecommand\thefigsubsep{,~}
\def\p@subfigure{\@nameuse{thefigure}\thefigsubsep}
\makeatother
\begin{document}
\chapter{Sample Chapter}
\appendix
%use russian alphabet for appendix counter
\makeatletter
\gdef\thechapter{\@Asbuk\c@chapter}
\makeatother
\chapter{Sample Appendix}
Reference \ref{fig_images}, also \ref{fig_image1} and \ref{fig_image2}.
\begin{figure}
\centering
\subcaptionbox{\label{fig_image1}}{\includegraphics[width=0.15\linewidth]{image1}}
\hspace{0.15\linewidth}
\subcaptionbox{\label{fig_image2}}{\includegraphics[width=0.15\linewidth]{image2}}
\caption[]{\label{fig_images}
Images:
\subref{fig_image1}~---~first;
\subref{fig_image2}~---~second;
}
\end{figure}
\end{document}
第二份附录(2011/08/19更新):
自 2011/08/18 的 1.1 版以来,该subcaption
软件包确实支持使用新选项“subrefformat=”对引用和子引用进行不同的外观和感觉。例如:
\documentclass[a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}
\usepackage[T2A]{fontenc}
\usepackage[demo]{graphicx}
\usepackage[config,font=small,labelsep=period]{caption}
\usepackage[subrefformat=parens]{subcaption}
\usepackage[unicode]{hyperref}
%use russian alphabet for subfigure counter
\makeatletter
\def\thesubfigure{\textit{\asbuk{subfigure}}}
\providecommand\thefigsubsep{,~}
\def\p@subfigure{\@nameuse{thefigure}\thefigsubsep}
\makeatother
\begin{document}
\chapter{Sample Chapter}
\appendix
%use russian alphabet for appendix counter
\makeatletter
\gdef\thechapter{\@Asbuk\c@chapter}
\makeatother
\chapter{Sample Appendix}
Reference \ref{fig_images}, also \ref{fig_image1} and \ref{fig_image2}.
\begin{figure}
\centering
\subcaptionbox{\label{fig_image1}}{\includegraphics[width=0.15\linewidth]{image1}}
\hspace{0.15\linewidth}
\subcaptionbox{\label{fig_image2}}{\includegraphics[width=0.15\linewidth]{image2}}
\caption[]{\label{fig_images}
Images:
\subref{fig_image1}~---~first;
\subref*{fig_image2}~---~second;
}
\end{figure}
\end{document}