Kapitel und dessen Name stehen nicht in derselben Zeile

Kapitel und dessen Name stehen nicht in derselben Zeile

Entschuldigen Sie die Unklarheit.

Ich bin ein LaTeX-Anfänger und habe Probleme damit, den Kapitelnamen mit der Kapitelnummer in derselben Zeile zu platzieren, in der sich das Kapitel befindet. So sollte es sein:

Bildbeschreibung hier eingeben

Der Code selbst wurde von mir geändert, um den Anforderungen der Universität zu entsprechen. Die verwendete Klasse ist „Report“, jedoch im modifizierten „Rackham“-Stil (von der University of Michigan, glaube ich).

Der minimal funktionierende Code ist MS Thesis.tex:

% The packages used here are just a sample. You may need others, and may not need some of these.
% A style was adopted from Rachkam style that can be found in internet
\documentclass[12pt,oneside]{report} % right-side equation numbering, 12 point font, print one-sided 
\usepackage{csm}         % Use the following thesis style file
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\bibliographystyle{humanbio}

\titlepage{The Title of Your Dissertation}{Your Name}

% Begin the front matter 
\initializefrontsections

\startabstractpage

Here is a brief explanation of thesis goes. 

% Table of contents, list of figures, etc.
\tableofcontents     % Required
\listoffigures       % Required if there is more than one figure
\listoftables        % Required if there is more than one table
\listofsymbols       % Required if there is more than one equation 

% Optional Acknowledgements page
\startacknowledgementspage
%\input{Intro/Acknowledgements}
\label{Acknowledgements}

\startthechapters 

 \chapter{Introduction}
This chapter disccuses an importance of converting public transportation to renewable energy sources. 
 \label{chap:Intro}

\section{Motivation}
The traditional  petroleum based fuels like gasoline is, first of all, ecologically unsafe. 

\section{Objectives}
Alternative energy sources such as electric batteries can ecomically be installed in the public transportation and used. 

\section{Methodology}

 \chapter{Background and Literature Review}

\chapter{Transporation Fees}
\section{the cost of public transportation in big cities}

\end{document}

Der folgende Stilcode ist lang, führt jedoch dazu, dass das Inhaltsverzeichnis (nach dem Stilcode) wie folgt aussieht.

% The 'csm' style, which is called by \usepackage{csm} in the main code
\typeout{  }
\typeout{Substyle `rac' for Rackham dissertation.}
\typeout{  }

%-- Page styles --

\def\ps@chappage{% The first page of each chapter has bottom-center page numbers
 \def\@oddhead{}
 \def\@oddfoot{\hfil \rm \thepage \hfil}
 \let\@evenhead\@oddhead 
 \let\@evenfoot\@oddfoot
}

\def\ps@plain{%
% \def\@oddhead{\hfil \rm \thepage \hfil} % These two lines of code make top-center page numbers on other pages
% \def\@oddfoot{}
 \def\@oddhead{} % These two lines of code make bottom-center page numbers on other pages
 \def\@oddfoot{\hfil \rm \thepage \hfil}
 \let\@evenhead\@oddhead 
 \let\@evenfoot\@oddfoot
}

%-- Margins --
\if@twoside \oddsidemargin 0.5in \evensidemargin 0in \marginparwidth .6in \textheight=8.95in
\else \oddsidemargin 0.5in \marginparwidth .9in \textheight=9.0in\fi% left margin=1in + oddsidemargin, marginparwidth: text box for margin notes
\topmargin -0.65in \headheight 0.35in \headsep 0.35in \footskip 0.5in % header and footer margins
\textwidth=6.0in % width of the text body on a page
% The top margin = 1in plus vspace. For some reason, need to subtract 0.35in also.
\def\vertadjust{\vspace{-0.35in}} % Required for proper vertical spacing.
\def\twoinmar{\vertadjust\vspace{0.25in}} % Two inch top margin
\def\twohalfinmar{\vertadjust\vspace{1.5in}} % Two and a half inch top margin

%-- Front pages --

% This \ttlpg is the same as \titlepage in report.sty.
\def\ttlpg{\@restonecolfalse \if@twocolumn \@restonecoltrue \onecolumn
 \else \newpage \fi \thispagestyle{empty} \c@page \z@}

\def\titlepage#1#2{
 \ttlpg
 \begin{singlespace}
 \hbox{ }
 \twohalfinmar
 \begin{center}
 \begin{onehalfspacing} % For the `Large' font size, this will look single spaced.
\vspace{2in}  
  {\Large\MakeUppercase{#1} \mbox{}} \\
 \end{onehalfspacing}
  \vfill
  by \\
  \vspace{2ex} % ex is the height of the lowercase 'x' for the current font.
  #2 \\
 \end{center}
 \end{singlespace}
}

\def\initializefrontsections{
 \setcounter{page}{1}   % -- begins with "ii"
 \pagestyle{chappage}   % -- numbers at bottom
 \renewcommand{\thepage}{\roman{page}}   % roman numeral
}

%  ABSTRACT 
\def\startabstractpage{
 \newpage
 \twoinmar
 \addcontentsline{toc}{chapter}{ABSTRACT}
 \hbox{ }
 \twoinmar
 \centerline{\large\bf ABSTRACT}
 \vspace{0.25in}
}

\def\startacknowledgementspage{
 \newpage
 \addcontentsline{toc}{chapter}{ACKNOWLEDGEMENTS}
 \hbox{ }
 \twoinmar
 \centerline{\large\bf ACKNOWLEDGEMENTS}
 \vspace{0.25in}
}

%-- Table of contents and lists --

\def\dotfill{\leaders\hbox{$\m@th \mkern \@dotsep mu.\mkern \@dotsep mu$}\hfill}
\def\producetableofcontents{\tableofcontents}
\def\producelistoffigures{\listoffigures}
\def\producelistoftables{\listoftables}
\def\producelistofmaps{\listofmaps}
\def\producelistofappendices{\listofappendices}
\def\producelistofabbreviations{\listofabbreviations}

% The only difference is \dotfill instead of \hfil.
\def\l@chapter#1#2{\pagebreak[3]
 \vskip 1.0em plus 1pt \@tempdima 1.5em \begingroup 
 \parindent \z@ \rightskip \@pnumwidth
 \parfillskip -\@pnumwidth
 {\leavevmode #1}\dotfill \hbox to\@pnumwidth{\hss #2}\par
 \endgroup
}

\def\l@chap{\@dottedtocline{1}{1.0em}{1.5em}}
\def\l@section{\@dottedtocline{2}{2.5em}{3.0em}}
\def\l@subsection{\@dottedtocline{3}{5.5em}{3.0em}}
\def\l@subsubsection{\@dottedtocline{4}{8.5em}{3.0em}}

\setcounter{tocdepth}{3} % Number of section layers to show in TOC (i.e. section, subsection, subsubsection)
\setcounter{secnumdepth}{3} % Number of subsection layers to allow in document

\def\l@figure{\@dottedtocline{1}{1.0em}{3.5em}}
\let\l@table\l@figure
\let\l@map\l@figure
\let\l@anything\l@figure
\def\l@appendix{\@dottedtocline{1}{1.0em}{2.5em}}
\let\l@abbreviation\l@figure

\def\tableofcontents{%
 \newpage
 \@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn\fi
 \hbox{ }
 \twoinmar
 \centerline{\large\bf TABLE OF CONTENTS}
 \vspace{0.25in}
 \begin{onehalfspace}
  \@starttoc{toc}\if@restonecol\twocolumn\fi
 \end{onehalfspace} 
}

\def\listoffigures{%
 \newpage
 \addcontentsline{toc}{chapter}{LIST OF FIGURES}
 \@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn\fi
 \hbox{ }
 \twoinmar
 \centerline{\large\bf LIST OF FIGURES}
 \vspace{0.25in}
 \begin{onehalfspace}
  \@starttoc{lof}\if@restonecol\twocolumn\fi
  \addtocontents{lof}{\noindent\underline{\bf Figure}\hfill\rm\protect\newline}
 \end{onehalfspace}
}

\def\listoftables{%
 \newpage
 \addcontentsline{toc}{chapter}{LIST OF TABLES}
 \@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn\fi
 \hbox{ }
 \twoinmar
 \centerline{\large\bf LIST OF TABLES}
 \vspace{0.25in}
 \begin{onehalfspace}
  \@starttoc{lot}\if@restonecol\twocolumn\fi
  \addtocontents{lot}{\noindent\underline{\bf Table}\hfill\rm\protect\newline}
 \end{onehalfspace}
}

% Creating the list of symbols to appear in the thesis
% Created similarly to the abbreviations list
\def\listofsymbols{
 \newpage
 \addcontentsline{toc}{chapter}{LIST OF SYMBOLS}
 \@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn\fi
 \hbox{ }
 \twoinmar
 \centerline{\large\bf LIST OF SYMBOLS}
 \vspace{0.25in}
 \begin{onehalfspace}
   %\input{symbols}
 \end{onehalfspace} 
}

%-- Start chapters --

\def\thechapter {\@arabic\c@chapter}
\def\thesection {\@arabic\c@chapter.\@arabic\c@section}
\def\thefigure {\@arabic\c@chapter.\@arabic\c@figure}
\def\thetable {\@arabic\c@chapter.\@arabic\c@table}
\def\theequation {\@arabic\c@chapter.\@arabic\c@equation}

\newcounter{map}[chapter]
\def\themap{\@arabic\c@chapter.\@arabic\c@map}
\def\fps@map{tbp}
\def\ftype@map{1}
\def\ext@map{lom}
\def\fnum@map{Map \themap}
\def\map{\@float{map}}
\let\endmap\end@float
\@namedef{map*}{\@dblfloat{map}}
\@namedef{endmap*}{\end@dblfloat}

\def\startthechapters{%
 \def\@chapapp{CHAPTER}
 \addtocontents{toc}{\protect\mbox{ }\protect\newline\noindent{CHAPTER}\protect\newline}
 \addtocontents{toc}{\hbox{ }}
 \clearpage % This has to be before the rest.
 \if@twoside \ifodd\c@page \else \ttlpg \hbox{ }\fi\fi % For two-sided printing, make sure Chapter I starts on right-hand page. jg
 \clearpage
 \setcounter{chapter}{0}
 \setcounter{page}{1} % -- ...always begin with ii.
 \renewcommand{\thepage}{\arabic{page}}
 \pagestyle{plain}
 \def\tocname{toc}
}

\def\@chapter[#1]#2{%
 \ifnum \c@secnumdepth >\m@ne
  \refstepcounter{chapter}
  \typeout{\@chapapp\space\thechapter.}
  \addtocontents{toc}{\hbox{ }}
  \addcontentsline{toc}{chap}{\protect\numberline{\hbox{ }\hfill\thechapter.\hspace{5pt}}{\MakeUppercase{#1}}}
  \addtocontents{toc}{\hbox{ }}
 \else
  \addtocontents{toc}{\hbox{ }}
  \addcontentsline{toc}{chap}{#1}
  \addtocontents{toc}{\hbox{ }}
 \fi
 \if@twocolumn \@topnewpage[\@makechapterhead{#2}]
 \else \@makechapterhead{#2} \@afterheading \fi
}

\def\@makechapterhead#1{%
 \hbox{ }
 \twoinmar
 {\parindent 0pt \raggedright
  \ifnum \c@secnumdepth >\m@ne
  \centerline{\large\bf \@chapapp{} \thechapter} \par
  \vskip 0in \fi
  \begin{center}
   \centerline{\MakeUppercase{\large\bf #1}}
   %\large\bf #1
  \end{center}
  \nobreak
 }
 \@afterindenttrue
}

\def\section{\@startsection{section}{1}{\z@}{3.25ex plus 1ex minus
 .2ex}{2.3ex plus .2ex}{\normalsize\bf}}
\def\subsection{\@startsection{subsection}{2}{\z@}{3.25ex plus 1ex minus
 .2ex}{1.3ex plus .2ex}{\normalsize\bf}}
\def\subsubsection{\@startsection{subsubsection}{3}{\z@}{3.25ex plus
 1ex minus .2ex}{1.3ex plus .2ex}{\normalsize\bf}}

Bildbeschreibung hier eingeben

Der Code gibt möglicherweise einige Warnungen aus, da ich ihn gekürzt habe, um ihn hier zu veröffentlichen. Bitte drücken Sie die Eingabetaste.

Antwort1

Auf Ihrem Bild ist zu erkennen, dass Kapitelnummer und Titel in einer Zeile gedruckt sind.

  1. EINFÜHRUNG

Der Nummer ist kein Kapitel vorangestellt, was wir beheben können, aber zunächst gibt es eine völlig falsche

KAPITEL

am Anfang des Inhaltsverzeichnisses, das durch den \startthechaptersBefehl mit den Zeilen geschrieben wird

\addtocontents{toc}{\protect\mbox{ }\protect\newline\noindent{CHAPTER}\protect\newline}

 \addtocontents{toc}{\hbox{ }}

die entfernt werden sollten.

Die Inhaltsverzeichniszeile des Kapitels wurde geschrieben von

% The only difference is \dotfill instead of \hfil.
\def\l@chapter#1#2{\pagebreak[3]
 \vskip 1.0em plus 1pt \@tempdima 1.5em \begingroup 
 \parindent \z@ \rightskip \@pnumwidth
 \parfillskip -\@pnumwidth
 {\leavevmode\@chapapp\ #1}\dotfill \hbox to\@pnumwidth{\hss #2}\par
 \endgroup
}

wo ich \@chapappdavor hinzugefügt habe #1, also wird es je nach Kontext KAPITEL oder ANHANG schreiben.

verwandte Informationen