Text FormattingChapter Title

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
s.david
Posts: 43
Joined: Thu Sep 10, 2009 5:22 pm

Chapter Title

Post by s.david »

Hello,

How can I writte the chapter number and chapter title in the same line, and if the title is too long, the second line begins from the begining of the line, not under the first word of the title. For example, in this code:

Code: Select all

\documentclass[a4paper,12pt,openany]{memoir}
\usepackage{titlesec}
\usepackage{titletoc}
\begin{document}
\chapter{This is a regular test chapter title in the same line of the chapter number}
\end{document}
Thanks in advance

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Chapter Title

Post by Stefan Kottwitz »

You will find possibilities in the titlesec documentation, for instance the block shape:

Code: Select all

\titleformat{\chapter}[block]
  {\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
Stefan
LaTeX.org admin
s.david
Posts: 43
Joined: Thu Sep 10, 2009 5:22 pm

Chapter Title

Post by s.david »

Stefan_K wrote:You will find possibilities in the titlesec documentation, for instance the block shape:

Code: Select all

\titleformat{\chapter}[block]
  {\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
Stefan
Thank you Stefan, you are really helping me.

Best regards
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Chapter Title

Post by localghost »

Just for the record. The memoir class has built-in mechanisms to translate that.

Code: Select all

\documentclass[12pt,a4paper,openany,english]{memoir}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{blindtext}

\makechapterstyle{custom}{%
  \renewcommand*{\printchapternum}{\chapnumfont \thechapter\quad}
  \renewcommand*{\afterchapternum}{}
}
\chapterstyle{custom}

\begin{document}
  \chapter{This is a regular test chapter title in the same line of the chapter number}
    \blindtext
\end{document}
More details can be found in the manual (Section 6.5.1 - Defining chapter styles, p. 81ff).


Best regards and welcome to the board
Thorsten
surrix
Posts: 9
Joined: Sun Nov 08, 2009 7:07 pm

Chapter Title

Post by surrix »

Hi,

I'm a total LaTeX noob and I've been searching forever for how to do this. Is there a simple way of doing this without resorting to a completely different doctype? I'm trying to make the chapter format be like this:

# Chaptertitle

For example,

1 Introduction

as it is in the ToC. I've already removed the word "Chapter" by using \renewcommand{\chaptername}{}, but now I just need to get the number and title on the same line. Can anyone help spell out how to do this simply, ideally without using other packages (surely there must be something built in for such a simple formatting task)?

Thanks
Last edited by cgnieder on Thu Apr 11, 2013 7:20 pm, edited 1 time in total.
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Chapter Title

Post by Juanjo »

Please, see this old thread about the same question.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
surrix
Posts: 9
Joined: Sun Nov 08, 2009 7:07 pm

Chapter Title

Post by surrix »

Juanjo wrote:Please, see this old thread about the same question.
Thanks!

For anyone who stumbles upon this thread again in the future, the code I used for my report class document was this in the preamble:

Code: Select all

\makeatletter
\renewcommand{\@makechapterhead}[1]{%
\vspace*{50 pt}%
{\setlength{\parindent}{0pt} \raggedright \normalfont
\bfseries\Huge\thechapter.\ #1
\par\nobreak\vspace{40 pt}}}
\makeatother
Nanayaw
Posts: 1
Joined: Thu Apr 11, 2013 1:29 pm

Re: Chapter Title

Post by Nanayaw »

Can you help me on why it is not working for me. It keeps highlighting the \chapter{company...} please help
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Re: Chapter Title

Post by Stefan Kottwitz »

Hi Nanayaw,

welcome to the forum!

I suggest that you would open a new topic and explain your problem in detail. I doubt that the people, who discussed here 4 yours ago, 2009, read your follow-up question, and that many other readers might see this topic of 2009 again. Just to improve your chance to get a solution.

Stefan
LaTeX.org admin
Post Reply