I've some problem with formatting my figure captions form my thesis.
First i'd like to describe my final result.
- Caption above: align left
- Caption below – first row (source): align right
- Caption below – rest: align left
Unfortunately
– Caption above: in the center
– Caption below: align right
I've tried all different kind of aligning-methods (\raggedleft, \begin{flushleft}
)
Thats what my code looks like
\documentclass[12pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{ragged2e}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{graphicx}
\usepackage{caption}
\makeatletter
\AtBeginDocument{%
\def\Ginclude@graphics#1{%
\begingroup\fboxsep=-\fboxrule
\fbox{\rule{\@ifundefined{Gin@@ewidth}{150pt}{\Gin@@ewidth}}{0pt}%
\rule{0pt}{\@ifundefined{Gin@@eheight}{100pt}{\Gin@@eheight}}}\endgroup}}
\makeatother
% Begin Document
\begin{document}
% Begin Figure
\begin{figure}[ht!]
\centering
\caption{Figure 1 - Title}
\includegraphics[width=0.6\textwidth]{demo}
\captionsetup{width=0.6\textwidth}
\caption*{Source: Source1\ \\Captiontex Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt \label{fig:3}}
\label{overflow}
\end{figure}
\end{document}
Best Answer
Supposedly your images may have different widths. As such, you'll be forced to adjust the width manually using
\captionsetup{width=X}
for everyfigure
.The use of
singlelinecheck=off
works to initiate the appropriate justification when the caption fits on a single line. Also, I've defined\imagesource{<source>}{<desc>}
which sets the image source using some pre-specified layout (as in your example). It's best to define macros for such things, as it promotes consistency.