The Package: Bicaption
The Package: Bicaption
Axel Sommerfeldt
https://gitlab.com/axelsommerfeldt/caption
2012/04/10
Abstract
This package supports the typesetting of bilangual captions.
Contents
1 Loading the package 2
2 Setting options 2
3 Additional options 3
5 A sample document 5
6 Customising lists 8
7 Language Selection 10
1
1 Loading the package
\usepackage This package will be loaded by
\usepackage[hoptionsi]{bicaption} .
The options for the bicaption package are the same ones as for the caption package and
specify settings which are used for the second language additionally. In fact
\usepackage[hoptionsi]{bicaption}
is identical to
\usepackage{bicaption}
\captionsetup[bi-second]{hoptionsi} .
When used with the babel or polyglossia package, the bicaption package should be loaded
after it, so the main language will be set automatically. See section 7 for details.
2 Setting options
\captionsetup
\captionsetup[bi]{hoptionsi}
do setup options which will be used for bilanguage captions additionally to the ones
which are setup for the specific floating environment.
\captionsetup[bi-first]{hoptionsi}
do setup options which will be used for the first heading of the bilanguage captions ad-
ditionally to the ones which are setup for the specific floating environment and the ones
which are setup by \captionsetup[bi]{. . . }.
\captionsetup[bi-second]{hoptionsi}
do setup options which will be used for the second heading of the bilanguage captions
additionally to the ones which are setup for the specific floating environment and the ones
which are setup by \captionsetup[bi]{. . . }.
2
4. Custom ‘bi’ settings (\captionsetup[bi]{. . . })
5. Custom ‘bi-first’ resp. ‘bi-second’ settings (\usepackage[. . . ]{bicaption} and
\captionsetup[bi-first]{. . . } resp. \captionsetup[bi-second]{. . . })
An example:
\usepackage[labelsep=quad,indention=10pt]{caption}
\usepackage[labelfont=bf]{bicaption}
\captionsetup[table]{labelfont=it,position=top}
causes the second heading of the bilingual caption inside table environments to be
typeset with the settings
labelsep=quad,indention=10pt,position=top,labelfont=bf .
To limit bi, bi-first, or bi-second options to specific environments one can use
multiple optional arguments for \captionsetup, e.g.:
\captionsetup[figure][bi-first][hoptionsi]
will limit the settings to the first heading of figure environments only. Please note that
the environment name has to be specified as first optional argument while the bilingual
selection as second one.
3 Additional options
These options are available additional to the ones offered by the caption package:
\captionsetup{bi-lang=second}
will cause that only the second heading is being typeset.
3
bi-singlelinecheck= bi-slc= Switches the common single-line-check on or off, i.e. when switched
on only a single check will be done for both captions, and the result
will affect both captions afterwards. So if only one caption is longer
than a single line, both captions will be treated as if they are longer
than a single line, even if the second one isn’t. (The default is on.)
bi-swap= bi-swap=
\captionsetup{bi-swap}
will swap the primary and secondary language, making the first lan-
guage the second one and vice versa. (The default is false.)
4
5 A sample document
\documentclass[english,ngerman]{article}
\usepackage{selinput}
\SelectInputMappings{adieresis={ä},germandbls={ß}}
\usepackage{babel}
\usepackage[lang=english,font=it]{bicaption}
\usepackage[format=hang]{subcaption}
\begin{document}
\begin{figure}[!htb]
\centering
\bisubcaptionbox
{Teilabbildung A\label{fig:test:A}}
{Subfigure A}[0.4\textwidth]{IMAGE}%
\qquad
\bisubcaptionbox
{Teilabbildung langer Titel B\label{fig:test:B}}
{Subfigure long title B}[0.4\textwidth]{IMAGE}%
\bicaption{Deutscher Titel}{English Title}
\label{fig:test}
\end{figure}
\captionsetup{bi-lang=both}
\begin{figure}[!htb]
\centering
\bisubcaptionbox[A]
{Und eine gaaaanz lange Caption: Teilabbildung A}
{Subfigure A}[0.4\textwidth]{IMAGE}%
\qquad
\bisubcaptionbox[B]
{Teilabbildung B}
{Subfigure B}[0.4\textwidth]{IMAGE}%
\bicaption[Abbildungsverzeichnistitel]
{Und eine noch viel viel viel
längere deutsche Beschriftung: Deutscher Titel}
{Short English heading}
\end{figure}
\captionsetup{bi-slc=0}
\begin{figure}[!htb]
\centering
\bisubcaptionbox[A]
{Und eine gaaaanz lange Caption: Teilabbildung A}
{Subfigure A}[0.4\textwidth]{IMAGE}%
5
\qquad
\bisubcaptionbox[B]
{Teilabbildung B}
{Subfigure B}[0.4\textwidth]{IMAGE}%
\bicaption[Abbildungsverzeichnistitel]
{Und eine noch viel viel viel
längere deutsche Beschriftung: Deutscher Titel}
{Short English heading}
\end{figure}
\captionsetup{slc=0}
\begin{figure}[!htb]
\centering
\bisubcaptionbox[A]
{Und eine gaaaanz lange Caption: Teilabbildung A}
{Subfigure A}[0.4\textwidth]{IMAGE}%
\qquad
\bisubcaptionbox[B]
{Teilabbildung B}
{Subfigure B}[0.4\textwidth]{IMAGE}%
\bicaption[Abbildungsverzeichnistitel]
{Und eine noch viel viel viel
längere deutsche Beschriftung: Deutscher Titel}
{Short English heading}
\end{figure}
\end{document}
6
IMAGE IMAGE
(a) Teilabbildung A (b) Teilabbildung langer Titel B
(a) Subfigure A (b) Subfigure long title B
IMAGE IMAGE
(a) Und eine gaaaanz lange Caption: (b) Teilabbildung B
Teilabbildung A (b) Subfigure B
(a) Subfigure A
Abbildung 2: Und eine noch viel viel viel längere deutsche Beschriftung: Deutscher Titel
Figure 2: Short English heading
IMAGE IMAGE
(a) Und eine gaaaanz lange Caption: (b) Teilabbildung B
Teilabbildung A (b) Subfigure B
(a) Subfigure A
Abbildung 3: Und eine noch viel viel viel längere deutsche Beschriftung: Deutscher Titel
Figure 3: Short English heading
IMAGE IMAGE
(a) Und eine gaaaanz lange Caption: (b) Teilabbildung B
Teilabbildung A (b) Subfigure B
(a) Subfigure A
Abbildung 4: Und eine noch viel viel viel längere deutsche Beschriftung: Deutscher Titel
Figure 4: Short English heading
7
6 Customising lists
list= As default both caption texts will be insert into the List of Figures resp. List of Tables. To
suppress the second entry just pass the option list=off to the bicaption package, e.g.:
\usepackage[lang=english,. . . ,list=off]{bicaption}
listtype+= Another option is separating the lists. For that purpose the option
can be used to tell the bicaption package to use a different list for the second caption
text. The given value will be appended to the current environment type; for example with
listtype+=X the list entries will be put into the list responsible for the types figureX
(= figure + X), tableX (= table + X) etc.
Such a hlist typei can be defined using \DeclareFloatingEnvironment offered
by the newfloat package, but some document classes or other packages offer macros for
defining new floating environment types (and their corresponding lists) as well.
A sample document:
\documentclass[a4paper]{article}
\usepackage{newfloat}
% Define the new floating environment type "figureEng"
\DeclareFloatingEnvironment[fileext=lof2]{figureEng}
[Figure][List of Figures]
% Define the new floating environment type "tableEng"
\DeclareFloatingEnvironment[fileext=lot2]{tableEng}
[Table][List of Tables]
\begin{document}
\listoffigures % typeset "Abbildungsverzeichnis"
\listoffigureEnges % typeset "List of Figures"
\begin{figure}
\centering
A placeholder for an image or whatever
\bicaption{Deutscher Text}{English text}
\end{figure}
\end{document}
8
A different approach is using one list for both languages, but with different formatting.
Since the caption package does not offer options and commands for customising the for-
mat of the lists, one need an additional package for this purpose, for example the titletoc
package:
\documentclass[a4paper]{article}
\usepackage{newfloat}
% Define the new floating environment type "figure2"
% Use the same file extension as for "figure" (.lof) here
\DeclareFloatingEnvironment[fileext=lof]{figure2}
% Define the new floating environment type "table2"
% Use the same file extension as for "table" (.lot) here
\DeclareFloatingEnvironment[fileext=lot]{table2}
\begin{document}
\renewcommand\listfigurename
{Abbildungsverzeichnis / List of Figures}
\listoffigures
\begin{figure}
\centering
A placeholder for an image or whatever
\bicaption{Deutscher Text}{English text}
\end{figure}
\end{document}
9
7 Language Selection
For language selection the bicaption package uses two macros internally:
\newcommand\captionmainlanguage{french}
\usepackage[hoptionsi]{bicaption}
Or one can specify the main language via \captionsetup after loading the bicaption
package, e.g.:
\usepackage[hoptionsi]{bicaption}
\captionsetup[bi-first]{lang=french}
When not using the babel or polyglossia package both approaches will have exactly the
same effect. But when using the babel or polyglossia package, and one want to spec-
ify the main caption language manually, the first approach is preferable since defining
\captionmainlanguage will suppress the automatic detection mechanism.
\selectcaptionlanguage{hfont-or-list-entryi}{hlanguagei}
For setting the language of the caption hfont-or-list-entryi will be \@firstoftwo, for
setting the language of the list entry hfont-or-list-entryi will be \@secondoftwo. 1
It defaults to \select@language (caption) resp. \selectlanguage (list entry)
offered by the babel and polyglossia package:
\providecommand*\selectcaptionlanguage[2]{%
#1{\select@language}{\selectlanguage}{#2}}
If you need to alter this, just either define \selectcaptionlanguage prior loading
the bicaption package, or redefine it afterwards.
Please note that all of this will only be relevant if the lang= option will be used. Other-
wise \selectcaptionlanguage won’t be used by the bicaption package at all.
1 \@firstoftwo and \@secondoftwo are defined in the LAT X kernel and simply pick either the 1st
E
or 2nd argument.
10