Page Layoutprinting section numbers in the margin in LaTeX

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
audreyk
Posts: 23
Joined: Fri Nov 14, 2008 5:57 am

printing section numbers in the margin in LaTeX

Post by audreyk »

Hello,

Can somebody tell me how to create hanging section numbers in the left margin of a document?

An example of what I am looking for appears here: http://unicast.org/misc/marginsec.png

I would appreciate seeing an example provided, with the document tex code in its entirety, as I am still fairly new to learning LaTeX.

I look forward to hearing from anyone ... soon :) .

Thanks,
audreyk

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

printing section numbers in the margin in LaTeX

Post by localghost »

audreyk wrote:[...] I would appreciate seeing an example provided, with the document tex code in its entirety, as I am still fairly new to learning LaTeX. [...]
Make a first approach on your own by looking at the titlesec package. In its documentation you will find some examples including the code.


Best regards
Thorsten¹
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

printing section numbers in the margin in LaTeX

Post by phi »

Here is a similar thread, including a solution for the standard classes:
http://www.latex-community.org/viewtopic.php?f=5&t=3573
If you use a KOMA-Script class, it's a bit easier. Search the manual for \othersectionlevelsformat, an example is given there.
audreyk
Posts: 23
Joined: Fri Nov 14, 2008 5:57 am

printing section numbers in the margin in LaTeX

Post by audreyk »

Thanks to all who have provided relevant links w/information, but after all that reading, I'm still not sure what I need to change in the code to get an elegant hanging section with as little code manipulation as possible.

Have a look at my Makefile code (set up to run sixteen units of a course filled with numerous chemical structures):

Code: Select all

Code, edit and compile here:
\documentclass{book}
\usepackage{fancyhdr}
\usepackage[asymmetric, total={336pt,624pt}, top=96pt, left=208pt, reversemp]{geometry}
\usepackage[fleqn]{amsmath}
\usepackage{chemarrow}
\usepackage{amssymb,amsfonts,wrapfig,amscd,times,curves,amsthm}
\usepackage{enumerate}
\usepackage{mdwlist}
\usepackage{sectsty}
\usepackage{fancyvrb}
\usepackage{paralist}
\usepackage{picinpar}
\usepackage{graphicx}
\usepackage{array}
\usepackage[hang,bottom]{footmisc}
\usepackage{dcolumn}
\usepackage{titlesec}
\usepackage{varioref}
\usepackage{array}
\usepackage{makeidx}
\usepackage[hang,bf,nooneline,justification=raggedright]{caption}
\usepackage{polynom}
\usepackage[T1]{fontenc}
\usepackage{mathpazo}
\usepackage{xymtexps,chmst-ps,lewis}
%--------------------------------------------------------------------------------
\pagestyle{fancy} \fancyhf{}
\renewcommand{\footrulewidth}{0.25pt}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[LE,RO]{\footnotesize \thepage}
\fancyfoot[LO]{\footnotesize{\itshape Organic Chemistry I}}
\fancyfoot[RE]{\footnotesize Chemistry $350$ / \textbf{Study Guide}}
\fancyfootoffset[LE,LO]{120pt} \fancypagestyle{plain}
\setlength{\marginparwidth}{6em}
\makeatletter
\renewcommand\footnoterule{
\vspace{1.5em} \kern-3\p@\hrule\@width.4\columnwidth \kern6\p@}
\makeatother
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
This is the code I'm using now to get the chapter title:

Code: Select all

Code, edit and compile here:
\chapter{Structure and Bonding}
\vspace{-3.5pc}
\hspace{-120pt}\rule{456pt}{0.25pt}
\vspace{0.25pc}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
This is the code I'm using now in my document to get a hanging section:

Code: Select all

\section{\hspace{-3em}1.12{\hspace{1em}}\rm{Drawing Chemical Structures}}
\rule{336pt}{0.25pt}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The trouble with my section code is that when the amount of section digits change, e.g., 1.1, 1.11, 10.12, etc. ..., I need to readjust the \hspace to align the titles with the rule, esp. for titles running on two lines or more. Also, I am manually typing in the section numbers.

Please see the sample PDFs for the \chapter and \section styles.

Note that I am also using the XyMTeX postscript package to create chemical structures throughout.

I would appreciate any help I can get at this point.

Thanks,
audreyk
Attachments
pg23.pdf
(66.05 KiB) Downloaded 628 times
pg3.pdf
(67.98 KiB) Downloaded 422 times
Post Reply