Text Formattingtitlesec | Reformatted Chapter, now Issues with Section

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
nicksy
Posts: 8
Joined: Sat Aug 27, 2011 9:59 pm

titlesec | Reformatted Chapter, now Issues with Section

Post by nicksy »

Hello,

I found help on this forum for reformatting \chapter{} so that the heading is displayed inline as e.g. 1 Introduction:

Code: Select all

\titleformat{\chapter}[hang]{\bfseries\huge}{\thechapter}{2pc}{}{}
\titlespacing*{\chapter}{0pt}{-12pt}{18pt}{}
and added the second line after reading the titlesec documentation to personalize my layout, and it looks fab :).


However, since doing this my \section, \subsection, etc. have stopped working. Now they just display as Normal text on their own lines separated by vertical spacing from surrounding paragraphs. No longer do they have section numbering, and no longer are they identifiable by increased font size or boldface, but they do still appear as (sub)sections (with numbering) in my Contents List and their hyperlinks still work. I even tried including "\titlelabel{\thetitle\quad}" to no avail.

I am plagued with errors about the section commands that I do not understand - missing numbers, illegal units (there number is of course proportional to the number of sections).



Also, if anyone can resolve the "Package etoolbox Warning: Patching '\begin' failed!
'AtBeginEnvironment' will not work" warning at the beginning that also plagued my last document please??


My (shortened) code so far, all packages included in case of clashes:

Code: Select all

\documentclass[pdftex,12pt,oneside,a4paper]{report}
\special{papersize=210mm,297mm} % to be on the safe side :p

\includeonly{Radiopharmacy}

\usepackage{microtype}
\usepackage{verbatim}
\usepackage{html}
\usepackage{url}
\usepackage[sort]{natbib}
\usepackage[pdftex,dvipsnames,usenames]{color}
\usepackage{hyperref}
\usepackage[style=long,nonumberlist,acronym,toc]{glossaries}%style=long,toc
\usepackage[pdftex]{graphicx}
\usepackage[margin=10pt,font=small,labelfont=bf,singlelinecheck=true,font=singlespacing]{caption}
\usepackage[all]{hypcap}
\usepackage{setspace}
\usepackage{amsmath, amsthm, amssymb}
\usepackage{tocloft}
\usepackage{listings}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{rotating}
\usepackage{enumitem}
\usepackage{titlesec}
\usepackage{lipsum}

%%%% 25mm to all but margin (left) side - 30mm!!!
\hoffset 4.6truemm \oddsidemargin =0pt \marginparwidth 0pt \marginparsep 0pt			%section for comments - not wanted
\voffset -0.4truemm \topmargin 0pt \headheight 0pt \headsep 0pt
%\headheight = 14.49998pt \headsep 10truemm		header environment     -------- Headheight 10pt!!!!
\textheight 232truemm \textwidth 155truemm		%sz of txt area
%
\footskip = 15truemm
\pagestyle{plain}

\bibpunct{(}{)}{;}{a}{,}{,}

\renewcommand{\cftchapleader}{\cftdotfill{\cftsecdotsep}}
\titleformat{\chapter}[hang]{\bfseries\huge}{\thechapter}{2pc}{}{}

\titlespacing*{\chapter}{0pt}{-12pt}{18pt}{}

\newcommand{\ts}{\textsuperscript}
\newcommand\tstrut{\rule{0pt}{2.5ex}}
\newcommand\bstrut{\rule[-1.5ex]{0pt}{0pt}}

%glossary entries

\begin{document}

%\input{./titlepage.tex}

\tableofcontents

\include{summarypage}

\include{listCompetency}

\include{Radiopharmacy}

\lipsum[1-2]

\bibliographystyle{agsm}%harvard = agsm

\renewcommand\bibname{References}
\phantomsection\addcontentsline{toc}{Chapter}{References}\bibliography{foo}

\end{document}
(Using work's MS XP, MikTex 2.9 and TeXnicCenter 1.0)


In Radiopharmacy.tex

Code: Select all

\chapter{Radiopharmacy}
\lipsum[1-2]

\section{Radiopharmacy Quality Control}
\lipsum[1]

\section{Support Room}
\lipsum[1]

\subsection{Hello World}
\lipsum[1]

\section{White Blood Cell Labelling}
\lipsum[1]

\section{Generator Change and Elution}
\lipsum[1]
Thank you

Nicky

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

nicksy
Posts: 8
Joined: Sat Aug 27, 2011 9:59 pm

titlesec | Reformatted Chapter, now Issues with Section

Post by nicksy »

Okay, the only solution I have found is to include 10 long lines of code re-stating all the 'standard' LaTeX heading definitions of the headings that I did not wish to customise. These can be found on page 27 of the Titlesec manual.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

titlesec | Reformatted Chapter, now Issues with Section

Post by localghost »

nicksy wrote:[…] However, since doing this my \section, \subsection, etc. have stopped working. Now they just display as Normal text on their own lines separated by vertical spacing from surrounding paragraphs. No longer do they have section numbering, and no longer are they identifiable by increased font size or boldface, but they do still appear as (sub)sections (with numbering) in my Contents List and their hyperlinks still work. I even tried including "\titlelabel{\thetitle\quad}" to no avail. […]
The described problem is incomprehensible due to a missing minimal example. The below code compiles flawlessly and doesn't show an irregularities.

Code: Select all

\documentclass[12pt,a4paper,english]{report}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\usepackage{babel}
\usepackage[raggedright]{titlesec}
\usepackage{blindtext}

\titleformat{\chapter}[hang]{\bfseries\huge\filright}{\thechapter}{2pc}{}{}
\titlespacing*{\chapter}{0pt}{-12pt}{18pt}{}

\begin{document}
  \blinddocument
\end{document}

Thorsten
Post Reply