Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I now know how to add images with captions but still need help how to tweak the captions.

\begin{figure}[h]
\begin{center}
\includegraphics[width=100mm]{01.jpg}
\caption*{\textbf{Bild 2.1:} Curtiss XP-23 mit einem Turbo-Superlader, 1923. Arbeitsergebnis von Sanford Moss, der US-Armee und der GE Company.}    
\end{center}
\end{figure}

And my code:

\documentclass[10pt]{report} 
\usepackage[german]{babel}
\usepackage[utf8]{inputenc}
\usepackage{titlesec}
\usepackage[left=35mm,right=35mm,top=35mm,bottom=35mm]{geometry} 
\usepackage{graphicx}
\titleformat{\section}{\huge\bfseries}{\thesection}{1em}{}
\titleformat{\chapter}{\huge\bfseries}{\thesection}{1em}{}
\titlespacing*{\section} {0pt}{3.5ex plus 1ex minus .2ex}{8.3ex plus .2ex}
\titlespacing*{\chapter}{0pt}{2.0cm}{2cm}
\linespread{1.8}
\setlength\parindent{0pt}
\begin{document}

Here is my code, I need to remove the linespacing of the caption and to left-align it and to remove Abbildung 1 because now I'm in the second chapter and it's the first image so Bild 2.1 or can you tell me how to connect the image to the chapter? enter image description here

share|improve this question
    
Why do you use caption*? Use caption. Don't user centerenvironment inside figure. –  Marco Daniel May 17 '13 at 15:40
    
@MarcoDaniel that was just an attempt to remove the automatic labeling just as in chapters and sections but it didn't work =) –  abdu May 17 '13 at 15:41
    
Can you provide a complete mwe with documentclass and end{document}. What do you want to achieve? –  Marco Daniel May 17 '13 at 15:42
    
@MarcoDaniel Ok Iadded my main code. I need to left-align the caption to remove the automatic labeling Abbildung 1: and to remove the linespacing for the caption. –  abdu May 17 '13 at 15:46
    
@MarcoDaniel ok everything works now =) I forgot to use \usepackage{caption}. But still want to know how to remove the line spacing. –  abdu May 17 '13 at 15:52
show 3 more comments

closed as too localized by Marco Daniel, egreg, Stefan Kottwitz May 17 '13 at 16:37

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers

The line spacing comes from \linespacing{1.8}. If you use package setspace it resets the line spacing to single spacing for footnotes and in floats:

\documentclass[10pt]{report}
\usepackage[ngerman]{babel}%
\usepackage[utf8]{inputenc}
\usepackage{titlesec}
\usepackage[left=35mm,right=35mm,top=35mm,bottom=35mm]{geometry}
\usepackage{graphicx}
\titleformat{\section}{\huge\bfseries}{\thesection}{1em}{}
\titleformat{\chapter}{\huge\bfseries}{\thesection}{1em}{}
\titlespacing*{\section} {0pt}{3.5ex plus 1ex minus .2ex}{8.3ex plus .2ex}
\titlespacing*{\chapter}{0pt}{2.0cm}{2cm}
\setlength\parindent{0pt}% consider package `parskip' 

\usepackage{setspace}
\setstretch{1.8}
\usepackage[bf]{caption}
\addto\captionsngerman{%
  \renewcommand*{\figurename}{Bild}%
}
\begin{document}

\begin{figure}[h]
\centering
\includegraphics[width=100mm]{01.jpg}
\caption{Curtiss XP-23 mit einem Turbo-Superlader, 1923.
Arbeitsergebnis von Sanford Moss, der US-Armee und der GE Company.}
\end{figure}

\end{document}

Caption

Remarks:

  • I have changed the babel language to ngerman (new spelling). Language german is for old texts of the previous century.
  • \centering instead of environment center avoids additional vertical space.
  • Because of package babel the redefinition of \figurename should be done in \captions<language>.
share|improve this answer
add comment
  • Do not use \linespread because it modifies the line spread everywhere in the document, including footnotes and captions. This is rarely what you want. Instead, use the \setstretch command from the setspace package, which will affect the line spread of the main text.
  • You can customise the appearance of captions with the \captionsetup command from the caption package; see my code below. No need to resort to \caption* and typeset the caption name and number manually, then; simply use \caption.
  • Refrain from using a center environment in a figure environment; see Should I use center or centering for figures and tables? for more details about why you should prefer the \centering declaration, in that case.
  • By default, in the report class, figures will be numbered within chapters, as desired.
  • There was a mistake in one argument of the \titleformat command you use to format chapter headings; see my correction below.

enter image description here

\documentclass[10pt]{report} 
\usepackage[german]{babel}
\usepackage{caption}
\usepackage[utf8]{inputenc}
\usepackage{titlesec}
\usepackage[left=35mm,right=35mm,top=35mm,bottom=35mm]{geometry} 
\usepackage[demo]{graphicx}
\titleformat{\section}{\huge\bfseries}{\thesection}{1em}{}
\titleformat{\chapter}{\huge\bfseries}{\thechapter}{1em}{}  % <--- I substituted
                                                            % "\thechapter" for
                                                            % the "\thesection", here
\titlespacing*{\section} {0pt}{3.5ex plus 1ex minus .2ex}{8.3ex plus .2ex}
\titlespacing*{\chapter}{0pt}{2.0cm}{2cm}
\setlength\parindent{0pt}
\captionsetup[figure]{%
    name=Bild,%
    labelfont=bf,%
    justification=raggedright%
}

\usepackage{setspace}
\setstretch{1.8}

\usepackage{lipsum}

\begin{document}


\setcounter{chapter}{1}     % just to pretend there was a first 
                            % chapter before the one entitled "foo"
\chapter{foo}

\lipsum[2]

\section{My first section}

\begin{figure}[h]
\centering
\includegraphics[width=100mm]{01.jpg}
\caption{Curtiss XP-23 mit einem Turbo-Superlader,
    1923. Arbeitsergebnis von Sanford Moss, der US-Armee und der GE Company.}    
\end{figure}

\begin{figure}[h]
\centering
\includegraphics[width=100mm]{01.jpg}
\caption{Some other picture}    
\end{figure}

\end{document}

Note: don't forget to remove the demo option of the graphicx package, or you will get black rectangles in place of your external images.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.