[Tex/LaTex] How to format bicaption

captionsindentation

I've got some troubles with formatting the bicaption package and would like to ask, if someone can point out some hints to solve it.

I guess it was too late yesterday, so first my dear apologies Axel!
Also sorry for not providing an MWE, which I included now:

\documentclass[12pt,halfparskip,BCOR0pt,DIV12]{scrartcl}
\usepackage[utf8]{inputenc}               
\usepackage[T1]{fontenc}                 
\usepackage[ngerman]{babel}             
\usepackage[intlimits]{amsmath}
\usepackage[a4paper,left=2.5cm, right=2.5cm,top=2.5cm, bottom=2cm,headsep=0.865cm]{geometry}
\usepackage{graphicx}
\usepackage{bicaption}
\captionsetup[figure][bi]{labelfont=it, font=it,justification=raggedright, singlelinecheck=false, margin={0mm,0mm}}
\captionsetup[figure][bi-first]{name=Bild}
\captionsetup[figure][bi-second]{name=Fig.}
\numberwithin{figure}{section}


\begin{document}

\section{Exemplum}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
\begin{figure}[h]
\includegraphics[width=\textwidth]{sample.png}
  \captionsetup{skip=0pt,}  
  \bicaption{Beispieltext}{Sample}  
  \label{fig:Q-pd}
\end{figure}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
\end{document}

I encountered two major problems and one open question:

  1. the command referring to bi-first is not working, caption is still "Abbildung", why is that?

  2. For the first cation "Abbildung" there is an indent, which I can only avoid with ident=-6pt at each bicaption within the Text, why is that and how can I remove indent for captions globally?
    I tried using raggedright as set here, with no effect, Raggedright with package ragged2e causes unexpected error and is not working.

  3. Format should look like this, given offset (tab) between type and number and text, caption one aligned with caption two:

    Bild x.xx:_{tab}_Text
    Fig. x.xx:_{tab}_Text

How can I set a distance between figure number and caption, that first and second caption are aligned, but with an offset?

Thanks for any suggestion and also thank you Axel for coming up with this great package!

Best Answer

  1. name= does not work with bi-captions controlled by babel (yet). If you want to change the name globally, use
\addto\captionsngerman{\renewcommand\figurename{Bild}}

instead. If you want to change the name for bi-captions only, you (currently) need a helper construct as workaround like this:

\captionsetup[figure][bi-first]{ngermanname=Bild}
\makeatletter
\DeclareCaptionOption{ngermanname}{%
  \l@addto@macro\captionsngerman{\captionsetup{name={#1}}}}
\makeatother

But why does it work for the English caption? Because that caption language is not controlled by babel since you haven't given a second language to the bicaption package, for example with \usepackage[lang=english]{bicaption} or \captionsetup[bi-second]{lang=english}.

I just filled a ticket 1 and will fix this bug within the next weeks so the above workaround will not be necessary anymore.

Background: name=Bild will change the definition of \figurename which will be used to label the caption, but later on the bicaption package switches the language (using babel) to ngerman for the first caption, and this will change the definition of \figurename back to Abbildung. So to make this work I need to add a special handling of the option name= for bi-captions to my bicaption package, the argument needs to be stored and used after switching the language.

2a. I cannot reproduce this here. Is your TeX distribution up-to-date? Could you add an image of the unwanted indention? This is what it looks like on my PC (TeXlive 2015, updated today):

enter image description here

If "Abbildung" (or "Bild") is indented this could be caused by spaces inserted when setting languages. Do you extend \captionsngerman within your document? If yes, mind the unwanted spaces! http://www.komascript.de/signifikanteLeerzeichen (I'm sorry for the German link, I'm not aware of an English counterpart.)

2b. Changing justification=raggedright to justification=RaggedRight in your example document works fine here, too, what error message to you get?

  1. One could do this by defining an own caption format with \DeclareCaptionFormat which puts the label plus separator into a box of fixed width, for example:
\DeclareCaptionFormat{6cm}{\hbox to 6cm{#1#2\hfill}#3\par}
\captionsetup[figure][bi]{format=6cm}

(6cm will be far to much, so you need to adjust this value to your own needs.)

1 https://sourceforge.net/p/latex-caption/tickets/38/