1

I am currently formatting my thesis and need a specific format for my chapters. I want all my chapters to be in sans serif font, with each chapter beginning with a vertical line followed by the chapter number and then the title. I have provided an image of the desired result. For single-line chapter titles (like "Introduction"), I am not sure if it is possible for the text to be aligned with the bottom of the numbering.

Additionally, I want the header to display the chapter title in gray, italicized, sans serif text on the left on odd-numbered pages and on the right on even-numbered pages.

I will provide my preamble!

enter image description here

\documentclass[12p, twoside]{book}
\usepackage[hungarian]{babel}
\usepackage{cancel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[a4paper, margin=1.5in]{geometry}
\usepackage{graphicx}
\usepackage{mathtools}
\usepackage{leipzig}
\usepackage{fancyhdr}
\usepackage[weather]{ifsym}
\usepackage{capt-of}
\usepackage{multicol}
\usepackage{booktabs}
\usepackage{sansmath, amsfonts}
\usepackage{pifont}
\usepackage{indentfirst}
%\usepackage[backend=biber,style=authoryear,]{biblatex}
\usepackage{bbding}
\usepackage{stackengine}
\usepackage[table,xcdraw]{xcolor}
\usepackage{tikz-qtree-compat}
\usepackage{textcomp}
\usepackage{sectsty}
\usepackage{array}
\usepackage{bm}
%\usepackage{apacite}
\usepackage{natbib}
%\usepackage{hyperref}
\setcitestyle{authoryear, open={(},close={)}}
\setcitestyle{aysep={}} 
%\DeclareRobustCommand{\DEN}[3]{#2}
\pagestyle{plain}
\usepackage{amsmath}
\usetikzlibrary{patterns, patterns.meta, arrows.meta, decorations.pathreplacing, calligraphy, shapes.geometric, fit}
\usepackage{setspace}
\usetikzlibrary{tikzmark}
\usepackage{tipa}
\usepackage{linguex}
\usepackage{titlesec}
\usepackage{multirow}
\usepackage{tikz-cd}
\usepackage[cbgreek]{textgreek}
\setcitestyle{notesep={:}}

% Remove the horizontal rule above footnotes
\renewcommand{\footnoterule}{%
  \kern -3pt % Raise the rule slightly to avoid extra space
  \hrule width 0pt % Set the rule width to 0pt
  \kern 2.6pt % Space after the rule (if you decide to make it visible again)
}

\makeatletter
\renewcommand\@makefntext[1]{%
  \setlength{\parindent}{0pt}% No indentation at the beginning of paragraphs
  \begin{list}{}{% Settings for the hanging indent
    \setlength{\topsep}{0pt}% No extra space before the first item
    \setlength{\leftmargin}{10em}% Space for the footnote number
    \setlength{\labelwidth}{0em}% Footnote number does not consume space
    \setlength{\listparindent}{0pt}% No indentation for subsequent paragraphs in the footnote
    \setlength{\itemindent}{0pt}%
    \setlength{\parsep}{0pt}% No extra vertical space between paragraphs
  }
    \item[\textsf{\textsuperscript{\@thefnmark}}\hfil]% Right-align the footnote number and create space for the footnote text
    #1% The footnote text itself
  \end{list}%
}
\makeatletter

\addtolength{\skip\footins}{25pt} % Increase the space. Adjust the value as needed.

\tikzcdset{arrow style=tikz, diagrams={>=latex}}
\tikzset{inline/.style={column sep=2mm, cells={nodes={inner xsep=0pt}}}}

\titleformat{\subsection}
  {\normalfont\Large\sffamily\bfseries}{\thesubsection}{1em}{}


\renewcommand{\bfdefault}{sbc}
\allsectionsfont{\sffamily}

\renewcommand{\textbf}[1]{{\fontseries{bx}\selectfont{#1}}}


\renewcommand{\sfdefault}{cmss}
\newcommand{\sipa}[1]{\textsf{\textipa{#1}}}

% Update chaptermark (for article class, section is the highest level)
\renewcommand{\sectionmark}[1]{\markboth{#1}{}} 

\fancyfoot[CE,CO]{\thepage} % Even pages: Left footer, Odd pages: Right footer

\begin{document}

2 Answers 2

5

Don't load sectsty together with titlesec, as they fight over the same things.

\documentclass[12pt]{book}
\usepackage[T1]{fontenc}
\usepackage{fix-cm}
\usepackage[a4paper, margin=1.5in,heightrounded]{geometry}
\usepackage{titlesec}

\titleformat{\chapter}[block]
 {\sffamily\bfseries}
 {}
 {0pt}
 {\formatchaptertitle{\rule{6pt}{\ht\strutbox}\,\thechapter.}}
\titleformat{name=\chapter,numberless}[block]
 {\sffamily\bfseries}
 {}
 {0pt}
 {\formatchaptertitle{\rule{6pt}{\ht\strutbox}\hphantom{\,0.}}}

\newsavebox{\chapternumberbox}
\newcommand{\formatchaptertitle}[2]{%
  \sbox{\chapternumberbox}{\fontsize{2cm}{2.5cm}\selectfont#1}%
  \usebox{\chapternumberbox}\hspace{1pc}%
  \parbox[b]{\dimeval{\textwidth-\wd\chapternumberbox-1pc}}{%
    \LARGE\raggedright\MakeUppercase{#2}%
  }%
}

\begin{document}

\frontmatter

\tableofcontents

\mainmatter

\chapter{Introduction}

\chapter{The typology of syllabic consonants}

\end{document}

Remember that, if you need to give hints on line breaking in the chapter header, you have to use \protect\\ and, of course, give an optional argument without it to \chapter. For instance

\chapter[Some chapter title that needs a hint]{Some chapter title \protect\\ that needs a hint}

I also defined the numberless variant to print the rule and leave the space for a single digit.

enter image description here

enter image description here

For Hungarian:

\documentclass[12pt]{book}
\usepackage[T1]{fontenc}
\def\magyarOptions{defaults=hu-min,chapterhead=no}
\usepackage[magyar]{babel}
\usepackage{fix-cm}
\usepackage[a4paper, margin=1.5in,heightrounded]{geometry}
\usepackage{titlesec}

\titleformat{\chapter}[block]
 {\sffamily\bfseries}
 {}
 {0pt}
 {\formatchaptertitle{\rule{6pt}{\ht\strutbox}\,\thechapter.}}
\titleformat{name=\chapter,numberless}[block]
 {\sffamily\bfseries}
 {}
 {0pt}
 {\formatchaptertitle{\rule{6pt}{\ht\strutbox}\hphantom{\,0.}}}

\newsavebox{\chapternumberbox}
\newcommand{\formatchaptertitle}[2]{%
  \sbox{\chapternumberbox}{\fontsize{2cm}{2.5cm}\selectfont#1}%
  \usebox{\chapternumberbox}\hspace{1pc}%
  \parbox[b]{\dimeval{\textwidth-\wd\chapternumberbox-1pc}}{%
    \LARGE\raggedright\MakeUppercase{#2}%
  }%
}

\begin{document}

\frontmatter

\tableofcontents

\mainmatter

\chapter{Introduction}

\chapter{The typology of syllabic consonants}

\end{document}
6
  • Hi! I inserted it, but it doesn't seem to work. It doesn't produce anything. It works when I compile it as a minimal example, but it doesn't when I incorporate it into my thesis code.
    – KoNstantin
    Commented Jun 16 at 17:03
  • @KoNstantin Well, there can be several reasons… I guess the main one is babel-hungarian, that appears to be incompatible with almost anything.
    – egreg
    Commented Jun 16 at 19:14
  • @KoNstantin I added a workaround with magyar-babel.
    – egreg
    Commented Jun 16 at 19:18
  • I reordered the packages a bit and used your modified version of the code. Thanks a lot, now it works great.
    – KoNstantin
    Commented Jun 17 at 12:23
  • @KoNstantin As far as I can see, the magyar option is only documented in Hungarian and you probably understand that I'm not acquainted with the language, so I went to the code and discovered a promising option. See math.bme.hu/latex/magyarldf-doc.pdf if you know Hungarian.
    – egreg
    Commented Jun 17 at 12:46
0

It works great! Anyone who is interested, I leave the relevant packages and modifications below.

\documentclass[12pt, twoside, openany]{book} % openany avoids inserting a blank package after chapters.
\usepackage[T1]{fontenc}
\def\magyarOptions{defaults=hu-min,chapterhead=no}
\usepackage[magyar]{babel}
\usepackage{fix-cm}
\usepackage[a4paper, margin=1.5in, heightrounded]{geometry}
\usepackage{titlesec}
\usepackage[utf8]{inputenc}

%here are some custom modifications I used. Theese codes are for italic gray chapter titles on the header (even left, odd right) whitout the "Chapter No.".
\pagestyle{fancy}
\fancyhf{} % clear all header and footer fields
\fancyhead[LE]{\textit{\textsf{\textcolor{gray}{\nouppercase{\leftmark}}}}} % Even pages: Left header
\fancyhead[RO]{\textit{\textsf{\textcolor{gray}{\nouppercase{\leftmark}}}}} % Odd pages: Right header
\renewcommand{\headrulewidth}{.1pt} % optional: line under the header
\renewcommand{\footrulewidth}{0pt} % optional: line above the footer, 0pt means no line

\renewcommand{\chaptermark}[1]{%
    \markboth{#1}{}%
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .