Text FormattingMake \chapter not write "Chapter", center it, enumerate it

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
kulima
Posts: 23
Joined: Mon Aug 03, 2015 5:42 pm

Make \chapter not write "Chapter", center it, enumerate it

Post by kulima »

Greetings

I am new to LaTeX and trying to write an Inventory Report for the company.

i chose \documentclass[12pt]{report} as a class

made \chapter{blablubb} for the chapters

it gets printed out like

"Chapter 1
blablubb"

I rather have it like:
"1. blablubb" and that being centered.

How would i go about this?

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Make \chapter not write "Chapter", center it, enumerate it

Post by Johannes_B »

I would recommend to use KOMA-script instead. By using the default scrreprt, you don't get that extra line. You get centered chapter headings with:
\renewcommand{\raggedchapter}{\centering}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
kulima
Posts: 23
Joined: Mon Aug 03, 2015 5:42 pm

Make \chapter not write "Chapter", center it, enumerate it

Post by kulima »

scrreprt works well to remove the "Chapter"
I am not sure what KOMA-script is, does or how i use it though ;)

\renewcommand{\raggedchapter}{\centering} fails in my Document with LaTeX Error: \raggedchapter undefined.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Make \chapter not write "Chapter", center it, enumerate it

Post by Johannes_B »

Yes, this command is defined in KOMA-classes only to change the chapter tiles to be either left-aligned (standard) or centered or right-aligned. When working with a standard class like report, you need to call a package like titlesec and define the complete appearance of chapters by yourself.

Code: Select all

\documentclass{scrreprt}
\renewcommand{\raggedchapter}{\centering}
%\renewcommand{\raggedsection}{\centering}%if you want sections centered as well
%\addtokomafont{disposition}{\rmfamily}
\usepackage{blindtext}
\begin{document}
\blinddocument
\end{document}
The code above requires an up-to-date TeX-distribution.
Attachments
kulimaCenteredChapter.pdf
Output of the MWE with an up-to-date distribution.
(47.66 KiB) Downloaded 331 times
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
kulima
Posts: 23
Joined: Mon Aug 03, 2015 5:42 pm

Make \chapter not write "Chapter", center it, enumerate it

Post by kulima »

Thanks for the explanation.

scrreprt works, \raggedchapter not.
texlive version is "2014.20141024" according to Ubuntu. Guess that's too old?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Make \chapter not write "Chapter", center it, enumerate it

Post by Johannes_B »

Yes, it is too old. \raggedchapter has been introduced early this year to give the user the possibility to change the appearance of chapter and sections individually. There is also \raggedpart by the way.


Have you tried the commented line in the code above? It should work for you just fine.


All the information on what your version of KOMA-script can do is written in the documentation. You can call it in the terminal by typing and hitting enter:

Code: Select all

texdoc koma
KOMA can do a lot more than the standard classes, hence the manual is quite big. You can search for the specific term of raggedsection, but i would suggest to skim the table of contents as well.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
kulima
Posts: 23
Joined: Mon Aug 03, 2015 5:42 pm

Make \chapter not write "Chapter", center it, enumerate it

Post by kulima »

Tried the commented out code.
After the point where i put \renewcommand{\raggedsection}{\centering} \chapter and \section entries are centered.
Skimmed through the doc a little and put \renewcommand{\raggedsection}{\raggedright} diectly after \chapter entries.
So no i have my Chapters centered and my Sections aligned to the left (for some reason \raggedleft puts the sections to the right.

No idea if that would be the correct way but it works.
Thank you!
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Make \chapter not write "Chapter", center it, enumerate it

Post by Johannes_B »

This will do fine for now, bu i suggest to update to TeX Live 2015 some time in the future. There were a few very important updates in the very basic kernel of LaTeX.

The ragged commands refer to the margin. raggedleft means that the left side of the text is ragged, not one straight line forming the margin. The LaTeX commands often really just do what they say. chapter typesets a chapter, cite cites something. Quite simple ;-)
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
kulima
Posts: 23
Joined: Mon Aug 03, 2015 5:42 pm

Re: Make \chapter not write "Chapter", center it, enumerate

Post by kulima »

Pulled texlive packages from the next ubuntu release. Works now.
Well no idea what "ragged" means, since english is not my first language, time to look it up i guess ;)

All is good now, thanks again :)
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Make \chapter not write "Chapter", center it, enumerate it

Post by Johannes_B »

English isn't my native language either, look it up once, that will be enough ;-)

As an addendum, there are also environments (which don't apply here) that do the same.

{Flushleft} flushes all the content to the left, which is what \raggedright is doing. To not confuse them you really need to imagine content on a page which is flushed to the text border or ragged at the other. I cannot come up with other words, i am not a native either. Translating stuff in my head when i am in doubt sets me on the right track ;-)
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply