LaTeX forum ⇒ Page LayoutCustom Part Heading Styles Topic is solved

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

Postby chrarnold » Fri Feb 08, 2013 12:34 am

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
    1. \titleclass{\part}{top} % make part like a chapter
    2. \titleformat{\part}
    3. [display]
    4. {\centering\normalfont\Large}
    5. {\titlerule[3pt]\vspace{3pt}\titlerule[1pt]\vspace{3pt}\MakeUppercase{\partname} \thepart}
    6. {0pt}
    7. {\titlerule[1pt]\vspace{3pt}\titlerule[3pt]\vspace{4pc}\Large\MakeUppercase}
    8. %
    9. \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

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
cgnieder
Site Moderator
Posts: 1948
Joined: Sat Apr 16, 2011 7:27 pm
Location: Germany
Contact:

Postby cgnieder » Fri Feb 08, 2013 9:10 pm

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
Clemens
------------------------------
New German Q&A site about TeX: http://texwelt.de/wissen

Link:
BBcode:
HTML:
Hide post links
Show post links

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

Postby chrarnold » Mon Feb 11, 2013 12:47 pm

Hi there,

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

  1. \documentclass[a4paper,11pt]{book}
  2.  
  3. \usepackage[Rejne]{fncychap} %Select the Rejne style for chapters
  4. \usepackage{titlesec}
  5.  
  6. \begin{document}
  7.  
  8.  
  9. % 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...
  10.  
  11. %%%%%%%%%%%%%%%%%%
  12. \titleclass{\part}{top} % make part like a chapter
  13. \titleformat{\part}
  14. [display]
  15. {\centering\normalfont\Large}
  16. {\titlerule[3pt]\vspace{3pt}\titlerule[1pt]\vspace{3pt}\MakeUppercase{\partname} \thepart}
  17. {0pt}
  18. {\titlerule[1pt]\vspace{3pt}\titlerule[3pt]\vspace{4pc}\Large\MakeUppercase}
  19. \titlespacing*{\part}{0pt}{0pt}{20pt}
  20. %%%%%%%%%%%%%%%%%%
  21.  
  22.  
  23.  
  24. \part{Teil 1: Blablabla} %Should be styled like a chapter
  25. \newpage
  26.  
  27. \chapter{Section 1}
  28. \newpage
  29.  
  30. \part{Teil 2: Blablabla}
  31. \newpage
  32.  
  33. \chapter{Section 2}
  34. \newpage
  35.  
  36. \end{document}



I hope this helps!

Best
Christian

Link:
BBcode:
HTML:
Hide post links
Show post links

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

Postby chrarnold » Fri Mar 01, 2013 4:04 am

Hmm, no suggestions from anybody? What a bummer :cry:

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
cgnieder
Site Moderator
Posts: 1948
Joined: Sat Apr 16, 2011 7:27 pm
Location: Germany
Contact:

Postby cgnieder » Fri Mar 01, 2013 12:39 pm

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...

  1. \documentclass{book}
  2. \usepackage{titlesec}
  3. \usepackage{xcoffins}
  4.  
  5. \newcommand\headerdisplay[1]{%
  6. \huge
  7. \vskip.5\baselineskip
  8. \filcenter\MakeUppercase{#1}%
  9. \vskip.0\baselineskip
  10. }
  11. \NewCoffin\mytmpa
  12. \NewCoffin\mytmpb
  13. \newcommand\placeabove[3][0pt]{%
  14. \SetHorizontalCoffin\mytmpa{#2}%
  15. \SetHorizontalCoffin\mytmpb{#3}%
  16. \JoinCoffins*\mytmpb[hc,t]\mytmpa[hc,b](0pt,#1)%
  17. \TypesetCoffin\mytmpb
  18. }
  19.  
  20. \renewcommand\thepart{\arabic{part}}
  21. \titleclass{\part}{top} % make part like a chapter
  22. \titleformat{\part}[frame]
  23. {\normalfont}
  24. {\filcenter\placeabove[2\baselineskip]{\Large PART}{\huge\enspace\thepart\enspace}}
  25. {0pt}
  26. {\headerdisplay}
  27. \titlespacing*{\part}{0pt}{0pt}{20pt}
  28.  
  29. \titleformat{\chapter}[frame]
  30. {\normalfont}
  31. {\filcenter\placeabove[2\baselineskip]{\Large CHAPTER}{\huge\enspace\thechapter\enspace}}
  32. {0pt}
  33. {\headerdisplay}
  34.  
  35. \begin{document}
  36.  
  37. \part{Foo bar}
  38.  
  39. \chapter{A long, long chapter title that needs a few lines}
  40.  
  41. \end{document}


Regards
Clemens
------------------------------
New German Q&A site about TeX: http://texwelt.de/wissen

Link:
BBcode:
HTML:
Hide post links
Show post links

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

Postby chrarnold » Fri Mar 01, 2013 2:54 pm

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

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
cgnieder
Site Moderator
Posts: 1948
Joined: Sat Apr 16, 2011 7:27 pm
Location: Germany
Contact:

Postby cgnieder » Fri Mar 01, 2013 2:59 pm

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
Clemens
------------------------------
New German Q&A site about TeX: http://texwelt.de/wissen

Link:
BBcode: Topic is solved[/url]" title="Click to select post's link in BBcode format" onclick="this.focus();this.select();" />
HTML: Topic is solved</a>" title="Click to select post's link in HTML format" onclick="this.focus();this.select();" />
Hide post links
Show post links

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

Postby chrarnold » Fri Mar 01, 2013 6:27 pm

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

Link:
BBcode:
HTML:
Hide post links
Show post links

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

Postby zakaria » Wed Jul 15, 2015 4:04 pm

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

Link:
BBcode:
HTML:
Hide post links
Show post links

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

Postby Johannes_B » Wed Jul 15, 2015 10:45 pm

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.

  1. \documentclass{book}
  2. \usepackage{showframe}
  3. \usepackage{titlesec}
  4. \usepackage{xcoffins}
  5.  
  6. \newcommand\headerdisplay[1]{%
  7. \huge
  8. \vskip.5\baselineskip
  9. \filcenter\MakeUppercase{#1}%
  10. \vskip.0\baselineskip
  11. }
  12. \NewCoffin\mytmpa
  13. \NewCoffin\mytmpb
  14. \newcommand\placeabove[3][0pt]{%
  15. \SetHorizontalCoffin\mytmpa{#2}%
  16. \SetHorizontalCoffin\mytmpb{#3}%
  17. \JoinCoffins*\mytmpb[hc,t]\mytmpa[hc,b](0pt,#1)%
  18. \TypesetCoffin\mytmpb
  19. }
  20.  
  21. \renewcommand\thepart{\arabic{part}}
  22. \titleclass{\part}{top} % make part like a chapter
  23. \titleformat{\part}[frame]
  24. {\normalfont}
  25. {\filcenter\placeabove[2\baselineskip]{\Large PART}{\huge\enspace\thepart\enspace}}
  26. {0pt}
  27. {\headerdisplay}
  28. \titlespacing*{\part}{0pt}{7cm}{20pt}
  29.  
  30. \titleformat{\chapter}[frame]
  31. {\normalfont}
  32. {\filcenter\placeabove[2\baselineskip]{\Large CHAPTER}{\huge\enspace\thechapter\enspace}}
  33. {0pt}
  34. {\headerdisplay}
  35.  
  36. \begin{document}
  37.  
  38. \part{Foo bar}
  39.  
  40. \chapter{A long, long chapter title that needs a few lines}
  41.  
  42. \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.

Link:
BBcode:
HTML:
Hide post links
Show post links


Return to “Page Layout”

Who is online

Users browsing this forum: No registered users and 1 guest