[Tex/LaTex] How to specify the caption names in bilingual captions without babel or polyglossia

captionslanguagesnaming

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:

\documentclass{article}
\usepackage{caption}[2012/02/19 v3.2f]
\usepackage{bicaption}[2011/10/30 v1.0a]

\captionsetup[bi-first]{bi-first}
\captionsetup[bi-second]{bi-second}

\DeclareCaptionOption{bi-first}[]{%
  \def\tablename{Table}%
  \def\figurename{Figure}}
\DeclareCaptionOption{bi-second}[]{%
  \def\tablename{Alter-table}%
  \def\figurename{Alter-figure}}

\begin{document}

\begin{figure}
  \centering FIGURE
  \bicaption{XXX}{YYY}
\end{figure}

\begin{table}
  \centering TABLE
  \bicaption{XXX}{YYY}
\end{table}

\end{document}

However, I think a dedicated interface for usage of bicaption without babel/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 without babel/polyglossia in the upcoming version 1.1 of the bicaption package, so the example above could also be written as:

\documentclass{article}
\usepackage{caption}[2012/03/25 v3.3]
\usepackage{bicaption}[2012/04/09 v1.1]

\captionsetup[bi-first]{lang=first}
\captionsetup[bi-second]{lang=second}

\renewcommand\selectcaptionlanguage[2]{%
  \csname select#2language\endcsname}
\newcommand\selectfirstlanguage{%
  \def\tablename{Table}%
  \def\figurename{Figure}}
\newcommand\selectsecondlanguage{%
  \def\tablename{Alter-table}%
  \def\figurename{Alter-figure}}

\begin{document}

\begin{figure}
  \centering FIGURE
  \bicaption{XXX}{YYY}
\end{figure}

\begin{table}
  \centering TABLE
  \bicaption{XXX}{YYY}
\end{table}

\end{document}

Furthermore I have implemented \captionsetup[figure][bi-first]{name=Foo} in the upcoming version 3.3 of the caption package, so an alternative implementation would be:

\documentclass{article}
\usepackage{caption}[2012/03/25 v3.3]
\usepackage{bicaption}[2012/04/09 v1.1]

\captionsetup[figure][bi-first]{name=Figure}
\captionsetup[figure][bi-second]{name=Alter-figure}

\captionsetup[table][bi-first]{name=Table}
\captionsetup[table][bi-second]{name=Alter-table}

\begin{document}

\begin{figure}
  \centering FIGURE
  \bicaption{XXX}{YYY}
\end{figure}

\begin{table}
  \centering TABLE
  \bicaption{XXX}{YYY}
\end{table}

\end{document}

I'll release both of them within the next weeks.

Regarding the figurename option: This option was designed for usage with babel/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.