LaTeX forum ⇒ Fonts & Character SetsHow to change chapter title format

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Diogo Remoaldo
Posts: 22
Joined: Mon Apr 06, 2015 8:24 pm

How to change chapter title format

Postby Diogo Remoaldo » Fri Jul 29, 2016 6:58 pm

Hi I would like to make the chapters appear as the image in the appendix (Capítulo 1 - Introdução).

Thanks in advance for your time.

My code is as follows:

  1. \documentclass[a4paper,12pt]{report}
  2. \usepackage[utf8]{inputenc}
  3. \usepackage[portuguese]{babel}
  4. \usepackage[T1]{fontenc}
  5. \usepackage{amsmath}
  6. \usepackage{amsfonts}
  7. \usepackage{amssymb}
  8. \usepackage{epstopdf}
  9. \usepackage{float}
  10. \usepackage{graphicx}
  11. \usepackage[hidelinks]{hyperref}
  12. \usepackage{url}
  13. \usepackage[all]{hypcap}
  14. \usepackage{caption}
  15. \usepackage[paper=a4paper,top=3.5cm,bottom=2cm,right=1.5cm,left=3.0cm,twoside ,bindingoffset=1cm,marginparwidth=0in,marginparsep=0in]{geometry}
  16. \usepackage{array}
  17. \usepackage{booktabs}
  18. \usepackage{tabularx}
  19. \usepackage{indentfirst}
  20. \usepackage[export]{adjustbox}
  21. \usepackage[font=small,labelfont=bf]{caption}
  22. \usepackage{enumitem}
  23. \usepackage[titletoc]{appendix}
  24. \usepackage{titlesec}
  25. \usepackage{multirow}
  26. \captionsetup[table]{position=above}
  27. \usepackage{siunitx}
  28. %\usepackage[stretch=10,shrink=10]{microtype}
  29. \newcolumntype{C}{>{\centering\arraybackslash}m}
  30. \sisetup{per-mode=symbol}
  31. \usepackage{hhline}
  32. \captionsetup[table]{position=above}
  33. \setcounter{secnumdepth}{4}
  34. \DeclareSIUnit{\year}{ano}
  35. \titleformat{\paragraph}
  36. {\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}
  37. \titlespacing*{\paragraph}
  38. {0pt}{1.5ex plus 1ex minus .2ex}{1.5ex plus .2ex}
  39. \usepackage{eurosym}
  40. \usepackage{makeidx}
  41. \usepackage{subcaption}
  42. %\usepackage{afterpage}
  43. \usepackage{booktabs}
  44. \usepackage{longtable}
  45. \usepackage{placeins}
  46. \usepackage{appendix}
  47. \usepackage{newtxtext,newtxmath}
  48. \usepackage{times}
  49. \usepackage{setspace}
  50. \usepackage{lastpage}
  51. %\usepackage{microtype}
  52. \addto\captionsportuguese{
  53. \renewcommand\appendixname{Anexo}
  54. %\renewcommand\appendixpagename{Anexos}
  55. }
  56.  
  57. \usepackage{titlesec}
  58.  
  59. \newcommand{\chapfnt}{\fontsize{12}{19}}
  60. \newcommand{\secfnt}{\fontsize{12}{17}}
  61. \newcommand{\ssecfnt}{\fontsize{12}{14}}
  62.  
  63. \titleformat{\chapter}[display]
  64. {\normalfont\chapfnt\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\chapfnt}
  65.  
  66. \titleformat{\section}
  67. {\normalfont\secfnt\bfseries}{\thesection}{1em}{}
  68.  
  69. \titleformat{\subsection}
  70. {\normalfont\ssecfnt\bfseries}{\thesubsection}{1em}{}
  71.  
  72.  
  73. \setlength{\belowcaptionskip}{-2pt}
  74.  
  75. \setlist{itemsep=2.0pt}
  76.  
  77. \setlength{\textfloatsep}{10pt plus 1.0pt minus 2.0pt}
  78.  
  79. \setlength{\floatsep}{5pt plus 1.0pt minus 2.0pt}
  80. \setlength{\intextsep}{5pt plus 1.0pt minus 2.0pt}
  81.  
  82. \setlength{\parindent}{2.0em}
  83. \setlength{\parskip}{0.5em}
  84. %\renewcommand{\baselinestretch}{2.0}
  85.  
  86. \usepackage{fancyhdr}
  87.  
  88.  
  89. \pagestyle{fancy}
  90. \fancyhf{}% Clear header/footer
  91. \fancyhead[C]{\small\hfill Ordem dos Engenheiros-Região Norte\hfill\hbox{}\linebreak
  92. Colégio de Engenharia Mecânica\hfill Relatório nº 1}
  93. \fancyfoot[L]{\fontsize{10}{12} \selectfont Diogo Filipe Pereira Remoaldo}
  94. \fancyfoot[R]{\fontsize{10}{12} \selectfont \thepage / \pageref{LastPage}}
  95. \renewcommand{\headrulewidth}{0pt}
  96. \renewcommand{\footrulewidth}{0pt}
  97.  
  98.  
  99. \fancypagestyle{plain}{
  100. \fancyhf{}% Clear header/footer
  101. \fancyhead[C]{\small\hfill Ordem dos Engenheiros-Região Norte\hfill\hbox{}\linebreak
  102. Colégio de Engenharia Mecânica\hfill Relatório nº 1}
  103. \fancyfoot[L]{\fontsize{10}{12} \selectfont Diogo Filipe Pereira Remoaldo}
  104. \fancyfoot[R]{\fontsize{10}{12} \selectfont \thepage / \pageref{LastPage}}
  105. \renewcommand{\headrulewidth}{0pt}
  106. \renewcommand{\footrulewidth}{0pt}
  107. }
  108. \pagestyle{plain}% Set page style to plain.
  109.  
  110.  
  111.  
  112. \newgeometry{top=2cm,bottom=2cm,right=2.5cm,left=2.5cm,bindingoffset=0cm,marginparwidth=0in,marginparsep=0in}
  113. \title{Desenvolvimento de um edifício tipo "PassivHaus" para clima temperado (Português) integrando painéis "sandwich" estruturais e fontes de energia renováveis}
  114. \author{Diogo Filipe Pereira Remoaldo}
  115.  
  116.  
  117. \begin{document}
  118.  
  119. \begin{titlepage}
  120. \thispagestyle{empty}
  121. \centering
  122. %\includegraphics[width=.5\linewidth]{logofeupp}
  123.  
  124. \vspace*{0.5cm}
  125. \large{Departamento de Engenharia Mecânica}
  126.  
  127. \vspace*{2.5cm}
  128.  
  129. \huge{Desenvolvimento de um edifício tipo "PassivHaus" para clima temperado (Português) integrando painéis "sandwich" estruturais e fontes de energia renováveis}
  130.  
  131. \vspace*{4cm} \Large{Diogo Filipe Pereira Remoaldo}
  132.  
  133. %
  134. \vfill \normalsize{Porto, Setembro de 2015}
  135.  
  136. \end{titlepage}
  137.  
  138. \addtocounter{page}{+1}
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145. \renewcommand{\contentsname}{Índice}
  146. \tableofcontents
  147.  
  148.  
  149.  
  150. \renewcommand\listfigurename{Índice de Figuras}
  151.  
  152. \listoffigures
  153.  
  154.  
  155. \renewcommand\listtablename{Índice de Tabelas}
  156. \listoftables
  157.  
  158.  
  159.  
  160.  
  161.  
  162. \chapter{Introdução}
  163.  
  164. \section{Apresentação do Candidato}
Attachments
mycode.png
mycode.png (4.63 KiB) Viewed 2191 times
Introdução.png
Introdução.png (9.06 KiB) Viewed 2329 times
Last edited by Johannes_B on Mon Aug 01, 2016 11:50 am, edited 2 times in total.

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

Postby Johannes_B » Mon Aug 01, 2016 11:56 am

Since you have again not provided a minimal working example but rather a clutter of code, i will not present you with the ready made solution.
Just one hint: You are already changing the appearance of chapter headings in your code. So, you should be able to figure out how to change it to your needs.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

User avatar
Stefan Kottwitz
Site Admin
Posts: 8537
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Mon Aug 01, 2016 12:26 pm

Hi Diogo,

you have this line for configuring the chapter heading:

  1. \titleformat{\chapter}[display]
  2. {\normalfont\chapfnt\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\chapfnt}


Just change it. For example, remove the [display] option, similar to the following section line. The titlesec manual shows how to customize it.

Stefan
Site admin

Diogo Remoaldo
Posts: 22
Joined: Mon Apr 06, 2015 8:24 pm

Postby Diogo Remoaldo » Wed Aug 24, 2016 11:46 pm

Hi,

I ended up doing it. Johannes I came from vacations today and could only reply now, I don't know what I did wrong, I sent you my full code plus images, it still has almost no text because I am first setting the layout and than I will start writting. What else do you want me to send the next time?

Hope I haven't offended you, but I think you were a bit unfair.

Now I have another problem. I corrected my problema doing the following

  1. \titleformat{\chapter}
  2. {\normalfont\chapfnt\bfseries}{\chaptertitlename\ \thechapter-}{0em}{\chapfnt}
  3. \titlespacing*{\chapter}{0pt}{0pt}{*2}
  4. \titleformat{\section}
  5. {\normalfont\secfnt\bfseries}{\thesection-}{0em}{}
  6. \titleformat{\subsection}
  7. {\normalfont\ssecfnt\bfseries}{\thesubsection-}{0em}{}


But the - doesn't appear in the índex, I would like to Capítulo - 1 appear as follows in the índex. How can I work it around?


Return to “Fonts & Character Sets”

Who is online

Users browsing this forum: No registered users and 3 guests