General ⇒ fixing the horizontal space of section headings
fixing the horizontal space of section headings
In my document I have section headings that looks like this:
1. Section
1.1 Subsection
1.1.1 Subsubsection
1.1.1.1 Subsubsubsection
I want to fix the "indent" of all the "section" headings so they all line up.
what I want to do is something like this:
\makebox[8mm][l]{\thesection.\thesubsection.} ...
So all the section headings would start exactly 8mm from the left margin or whatever.
I tired the titlesec package, but the sep option lets me set the distance between the numbers and the title, but that space is kind of dynamic unless i use a monospaced font, which I don't want to do.
any ideas?
thanks
1. Section
1.1 Subsection
1.1.1 Subsubsection
1.1.1.1 Subsubsubsection
I want to fix the "indent" of all the "section" headings so they all line up.
what I want to do is something like this:
\makebox[8mm][l]{\thesection.\thesubsection.} ...
So all the section headings would start exactly 8mm from the left margin or whatever.
I tired the titlesec package, but the sep option lets me set the distance between the numbers and the title, but that space is kind of dynamic unless i use a monospaced font, which I don't want to do.
any ideas?
thanks
NEW: TikZ book now 40% off at Amazon.com for a short time.

fixing the horizontal space of section headings
If you use a standard document class, you can redefine an internal macro:The second definition prints the section numbers in the margin.
Code: Select all
\documentclass[english]{article}
\usepackage{babel}
\usepackage{blindtext}
\makeatletter
\def\@seccntformat#1{\hb@xt@ 36pt{\hfil\csname the#1\endcsname}\quad}
% \def\@seccntformat#1{\llap{\csname the#1\endcsname\quad}}
\makeatother
\begin{document}
\tableofcontents
\blinddocument
\end{document}
Re: fixing the horizontal space of section headings
Ahh thanks, after a bit of searching I figured out what each part of the command means except for the "\hb@xt@" part.
what does that bit of code do?
what does that bit of code do?
fixing the horizontal space of section headings
\hb@xt@ is an "abbreviation" for \hbox to, which creates a horizontal box of the given width. If you don't want to use these low-level primitives, you can also use LaTeX's \makebox command:
Code: Select all
\makebox[36pt][r]{...}
- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
fixing the horizontal space of section headings
LaTeX.org admin
Re: fixing the horizontal space of section headings
Hi,
as an addition to the above I would like to align the numbering in the margin to the left. Is it possible?
Thanks in advance!
/MIcke
as an addition to the above I would like to align the numbering in the margin to the left. Is it possible?
Thanks in advance!
/MIcke
Re: fixing the horizontal space of section headings
please reread my first posting in this thread.
Re: fixing the horizontal space of section headings
I´ve done that but I can´t get it right. After applying the code in your first post it looks like this:
____1__Text
__1.1__Text
1.1.1__Text
But I want it to look like this:
1______Text
1.1____Text
1.1.1__Text
____1__Text
__1.1__Text
1.1.1__Text
But I want it to look like this:
1______Text
1.1____Text
1.1.1__Text
fixing the horizontal space of section headings
OK, then use:
Code: Select all
\def\@seccntformat#1{\rlap{\hskip-36pt\csname the#1\endcsname}}
Re: fixing the horizontal space of section headings
Great!
Thanks!

Thanks!