Page LayoutCustom Part Heading Styles

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
chrarnold
Posts: 5
Joined: Fri Feb 08, 2013 12:20 am

Custom Part Heading Styles

Post by chrarnold »

Hi all,

I am new to this forum and I hope that someone can help me with the following issue. I searched for a similar post, but could not find anything so far.

I am writing my thesis, which consists not only of chapters, but also of two parts. I used the fncychap package to make the chapter title pages look nicer, which works wonderfully. Now I also want to make the part style nicer, and here I am struggling. I'd like to have the Rejne style for parts (and NOT for chapters, as defined in the fncychap package, and I already tried the following:
  1. Take the "fncychap.sty" and rename it to something else, replace \thechapter by \thepart, rename all new command definitions to prevent a re-definition of commands due to the inclusion of both the original "fncychap.sty" file and the modified one. However, this does not work. In fact, it messes up the chapter styles also, and the parts look the same as before.
  2. Using code I found to manually re-define the style of parts

    Code: Select all

    \titleclass{\part}{top} % make part like a chapter
    \titleformat{\part}
    [display]
    {\centering\normalfont\Large}
    {\titlerule[3pt]\vspace{3pt}\titlerule[1pt]\vspace{3pt}\MakeUppercase{\partname} \thepart}
    {0pt}
    {\titlerule[1pt]\vspace{3pt}\titlerule[3pt]\vspace{4pc}\Large\MakeUppercase}
    %
    \titlespacing*{\part}{0pt}{0pt}{20pt}
    This imitates the Conny chapter style, however, I am not able to modify this to imitate the Rejne style.
I would be extremely thankful if someone could help me here.


Thanks,
Christian

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

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Custom Part Heading Styles

Post by cgnieder »

Hi Christian,

Welcome to the LaTeX community!

Could you make the code snippet into a complete Infominimal working example, please? It will be easier to see what you have and what you want if we only need to copy and compile the code and are able to immediately can see what things look like.

Regards
site moderator & package author
chrarnold
Posts: 5
Joined: Fri Feb 08, 2013 12:20 am

Custom Part Heading Styles

Post by chrarnold »

Hi there,

no problem, here is a minimal example with a few comments to illustrate the problem:

Code: Select all

\documentclass[a4paper,11pt]{book}

\usepackage[Rejne]{fncychap} %Select the Rejne style for chapters
\usepackage{titlesec}

\begin{document}


% As the fncychap package re-styles only chapters but not parts, a workaround is to redefine the \part style manually. The following imitates the Conny style, but I do not know how to imitate the Rejne style...

%%%%%%%%%%%%%%%%%%
\titleclass{\part}{top} % make part like a chapter
\titleformat{\part}
[display]
{\centering\normalfont\Large}
{\titlerule[3pt]\vspace{3pt}\titlerule[1pt]\vspace{3pt}\MakeUppercase{\partname} \thepart}
{0pt}
{\titlerule[1pt]\vspace{3pt}\titlerule[3pt]\vspace{4pc}\Large\MakeUppercase}
\titlespacing*{\part}{0pt}{0pt}{20pt}
%%%%%%%%%%%%%%%%%%



\part{Teil 1: Blablabla} %Should be styled like a chapter
\newpage

\chapter{Section 1}
\newpage

\part{Teil 2: Blablabla}
\newpage

\chapter{Section 2}
\newpage

\end{document}

I hope this helps!

Best
Christian
chrarnold
Posts: 5
Joined: Fri Feb 08, 2013 12:20 am

Re: Custom Part Heading Styles

Post by chrarnold »

Hmm, no suggestions from anybody? What a bummer :cry:
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Custom Part Heading Styles

Post by cgnieder »

chrarnold wrote:Hmm, no suggestions from anybody? What a bummer :cry:
Please no swearing! Unfortunately it happens that questions get overlooked or forgotten. That is not on purpose.

I would not use one package for chapter titles and another one for part titles. Inconsistencies are bound to happen... titlesec can be used for both. Below is an idea that uses the same style for both and tries to emulate the Rejne style...

Code: Select all

\documentclass{book}
\usepackage{titlesec}
\usepackage{xcoffins}

\newcommand\headerdisplay[1]{%
  \huge
  \vskip.5\baselineskip
  \filcenter\MakeUppercase{#1}%
  \vskip.0\baselineskip
}
\NewCoffin\mytmpa
\NewCoffin\mytmpb
\newcommand\placeabove[3][0pt]{%
 \SetHorizontalCoffin\mytmpa{#2}%
 \SetHorizontalCoffin\mytmpb{#3}%
 \JoinCoffins*\mytmpb[hc,t]\mytmpa[hc,b](0pt,#1)%
 \TypesetCoffin\mytmpb
}

\renewcommand\thepart{\arabic{part}}
\titleclass{\part}{top} % make part like a chapter
\titleformat{\part}[frame]
  {\normalfont}
  {\filcenter\placeabove[2\baselineskip]{\Large PART}{\huge\enspace\thepart\enspace}}
  {0pt}
  {\headerdisplay}
\titlespacing*{\part}{0pt}{0pt}{20pt}

\titleformat{\chapter}[frame]
  {\normalfont}
  {\filcenter\placeabove[2\baselineskip]{\Large CHAPTER}{\huge\enspace\thechapter\enspace}}
  {0pt}
  {\headerdisplay}

\begin{document}

\part{Foo bar}

\chapter{A long, long chapter title that needs a few lines}

\end{document}
Regards
site moderator & package author
chrarnold
Posts: 5
Joined: Fri Feb 08, 2013 12:20 am

Re: Custom Part Heading Styles

Post by chrarnold »

Hi there,

first, thanks very much for the reply. In American English (which I am using), "What a bummer" is not a swear word at all, and I had no intention to swear, why would I? I understand fully that my issue is rather specific and is easily overlooked.

I tried to compile your code, but I have difficulties with the \usepackage{xcoffins} statement. LaTeX Error: File `xcoffins.sty' not found. How exactly do I install this experimental package manually? I downloaded the sources from CTAN, but I cannot run latex or pdflatex on the *dtx and *ins without errors. I get similar errors as the own above when doing this...

Thanks a lot, I appreciate your time!
Christian
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Custom Part Heading Styles

Post by cgnieder »

chrarnold wrote:first, thanks very much for the reply. In American English (which I am using), "What a bummer" is not a swear word at all, and I had no intention to swear, why would I? I understand fully that my issue is rather specific and is easily overlooked.
Well, maybe »swear« is the wrong wording. I'm no native speaker... to me »bummer« has unfriendly connotations. If I'm wrong then ignore my comment.
chrarnold wrote:I tried to compile your code, but I have difficulties with the \usepackage{xcoffins} statement. LaTeX Error: File `xcoffins.sty' not found. How exactly do I install this experimental package manually? I downloaded the sources from CTAN, but I cannot run latex or pdflatex on the *dtx and *ins without errors. I get similar errors as the own above when doing this...
You should best update your TeX distribution then instead of trying to manually install xcoffins. The package relies on quite a number of additional packages. xcoffins is part of both TeX Live 2012 and MiKTeX 2.9.

Regards
site moderator & package author
chrarnold
Posts: 5
Joined: Fri Feb 08, 2013 12:20 am

Re: Custom Part Heading Styles

Post by chrarnold »

Hi, thanks, a good suggestion. I installed it, and now everything works wonderfully. Thank you for your help, you just made my day!

Best
Christian
zakaria
Posts: 2
Joined: Wed Jul 15, 2015 3:41 pm

Re: Custom Part Heading Styles

Post by zakaria »

Dear cgnieder,

I want to immitate the same part style and used your code as well. However, please can you tell me what should I edit in it so that the part title would be put in the vertical center of the page rather than the header.

Thanks in advance.

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

Custom Part Heading Styles

Post by Johannes_B »

You can change the titlespacing, in the following i used a value of 7cm, which ia almost the center of the page. You could measure the box and center it exactly on page, but taking an eye-value seems to be better.

Code: Select all

\documentclass{book}
\usepackage{showframe}
\usepackage{titlesec}
\usepackage{xcoffins}

\newcommand\headerdisplay[1]{%
	\huge
	\vskip.5\baselineskip
	\filcenter\MakeUppercase{#1}%
	\vskip.0\baselineskip
}
\NewCoffin\mytmpa
\NewCoffin\mytmpb
\newcommand\placeabove[3][0pt]{%
	\SetHorizontalCoffin\mytmpa{#2}%
	\SetHorizontalCoffin\mytmpb{#3}%
	\JoinCoffins*\mytmpb[hc,t]\mytmpa[hc,b](0pt,#1)%
	\TypesetCoffin\mytmpb
}

\renewcommand\thepart{\arabic{part}}
\titleclass{\part}{top} % make part like a chapter
\titleformat{\part}[frame]
{\normalfont}
{\filcenter\placeabove[2\baselineskip]{\Large PART}{\huge\enspace\thepart\enspace}}
{0pt}
{\headerdisplay}
\titlespacing*{\part}{0pt}{7cm}{20pt}

\titleformat{\chapter}[frame]
{\normalfont}
{\filcenter\placeabove[2\baselineskip]{\Large CHAPTER}{\huge\enspace\thechapter\enspace}}
{0pt}
{\headerdisplay}

\begin{document}

\part{Foo bar}

\chapter{A long, long chapter title that needs a few lines}

\end{document}
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