Graphics, Figures & TablesTwo-Lined Caption centering

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
0Jam
Posts: 10
Joined: Tue Dec 08, 2020 4:23 pm

Two-Lined Caption centering

Post by 0Jam »

Hey guys, I have a question about captions:

This is the first time ever that I want to use a two-lined caption. Usually, LaTeX puts the caption underneath a figure centralized, however when you put a \\ or \linebreak, or you just have a lot of text, now the caption will be all the way to the left.
This is my code for my Abb. 42:

Code: Select all

\begin{center}
	\includegraphics[width=\textwidth]{pics/wertigkeitsdiagramm}
	\captionof{figure}{Grundlegender Aufbau des Wertigkeitsdiagrammes \\ Eintragen von Hyperbeln gleicher Gewichtung}
	\label{fig:wertigkeitsdiagramm}
\end{center}
(Don't say anything about why "\captionof{figure}" is always used, that's cheese. I work for my prof. fixing up his scripts)
latex community question.PNG
As the second line of my caption is already underneath the text-start of the first one, I don't need to change anything with the captionstyle floats no? This is how I want it. All I want basically, is to move this caption as is to the middle, like is the case with Abb. 43., centralized based on the first line.
When I try to put a hspace, the "Abb.42:" stays left and a gap is created.
I believe LaTeX already thinks my line is full with the \\ and therefore puts the whole thing to the left.

Thank you very much!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
Bartman
Posts: 366
Joined: Fri Jan 03, 2020 2:39 pm

Two-Lined Caption centering

Post by Bartman »

Without a Infominimal working example we don't know which class you are working with and if you are already using the caption package.

The center environment can't prevent a possible page break between the figure and the caption. For that you would have to add a minipage environment inside the center environment.

Maybe the section 2.4 "Margins and further paragraph options" in the caption manual could fulfill your wish.
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Two-Lined Caption centering

Post by sommerfee »

It seems that a KOMA-Script document class is used? If yes take a closer look at section "3.20. Gleitumgebungen für Tabellen und Abbildungen" of the scrguide [1].

To me it seems that

Code: Select all

\setcaptionalignment{c}
(placed within the figure, right before \caption is what you are looking for.

[1] https://komascript.de/~mkohm/scrguide.pdf
0Jam
Posts: 10
Joined: Tue Dec 08, 2020 4:23 pm

Two-Lined Caption centering

Post by 0Jam »

I read through the KOMA Skript Documentation page 138 through 142 and the working command for simply shifting the whole thing to the right: \setcapmargin{1cm} works great
Thank you guys for your answers anyway! And - who in the world wouldn't be using something with the koma stuff like scrartcl as documentclass
Post Reply