I use Axel Sommerfeldt's bicaption package to setup bilingual captions.
bicaption
needs babel
's \selectlanguage
to set the different caption names for different languages. However, I cannot use the faculty of babel
/polyglossia
since it doesn't work for east Asian languages.
It is easy to set a name
option for the two captions, but I can't set different names for different types of floats. For example,
\documentclass{article}
\usepackage{caption}[2012/02/19 v3.2f]
\usepackage{bicaption}[2011/10/30 v1.0a]
\captionsetup[bi-first]{name=Foo}
\captionsetup[bi-second]{name=Bar}
\begin{document}
\begin{figure}
\centering FIGURE
\bicaption{XXX}{YYY}
\end{figure}
\begin{table}
\centering TABLE
\bicaption{XXX}{YYY}
\end{table}
\end{document}
I tried
\captionsetup[bi-first,figure]{name=Foo}
there's no effect. And I tried
\captionsetup[bi-first]{figurename=Foo}
then I got an error
! Package caption Error: Can be used only in preamble.
So what can I do? Is there a simple way to use bicaption
without babel
?
In an older version of caption
package (e.g. 2011/11/10 v3.2e), figurename
and table
options can be used in document
environment, but the latest caption
allows them only to be used in the preamble. I cannot see any advantage to set \@onlypreamble\caption@SetName
. However, even if I use the old version of caption
, I still cannot set the name for user-defined (via newfloat
package) floats in bilingual captions.
Note: I do not like the \bicaption
provided by ccaption
package, it is complicated to use. And I have the ability to define my own version of \bicaption
, but it seems also a bad option.
Currently I can use this weird trick:
\captionsetup[bi-first]{font=bi-first}
\captionsetup[bi-second]{font=bi-second}
\DeclareCaptionFont{bi-first}{%
\def\tablename{Table}%
\def\figurename{Figure}}
\DeclareCaptionFont{bi-second}{%
\def\tablename{Alter-table}%
\def\figurename{Alter-figure}}
Best Answer
IMHO your trick is fine, if you want to make it looking a little bit less weird you could use
\DeclareCaptionOption
instead of\DeclareCaptionFont
:However, I think a dedicated interface for usage of
bicaption
withoutbabel/polyglossia
would be great, so I will design it in the next days... (Please stay tuned.)(2012-04-09) ...done. I have added a small interface for using the
lang=
option withoutbabel/polyglossia
in the upcoming version 1.1 of thebicaption
package, so the example above could also be written as:Furthermore I have implemented
\captionsetup[figure][bi-first]{name=Foo}
in the upcoming version 3.3 of thecaption
package, so an alternative implementation would be:I'll release both of them within the next weeks.
Regarding the
figurename
option: This option was designed for usage withbabel/polyglossia
, therefore it could have caused trouble when used within the document text. And since it was never documented for usage within the document text I have added the\@onlypreamble
stuff.