Document Classes ⇒ custom chapter and section
custom chapter and section
I just stumbled upon this forum. It seems a great resource for learning latex and I am in dire need of some custom templating for *chapters* and *section*. I am not absolutely new to latex but have never worked in tweaking styles or the like.
I have uploaded the images of the format I would like to have here:
TITLE: SECTION: In the chapters, I do not need the picture in the background (parabolas). I just need *chapter 1* with the blue rectangle surrounding it, followed by the name.
Could you please suggest me how to go about?
thank you very much,
best, arun.
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
custom chapter and section
I would suggest you to use the titlesec package; the following code is an example that could give you some ideas to get the format for sections:
Code: Select all
\documentclass{book}
\usepackage[x11names]{xcolor}
\usepackage[explicit]{titlesec}
\titleformat{\section}[block]
{\normalfont\sffamily}
{\colorbox{blue!70}{\parbox[c][15pt][c]{30pt}{%
\hfil\color{white}\Large\thesection\hfil}}}
{0pt}
{\parbox{\linewidth}{%
\hspace*{1em}\color{DeepSkyBlue2}\large\sffamily#1\\[-8pt]\color{DeepSkyBlue2}\titlerule}}
\titlespacing*{\section}
{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\begin{document}
\chapter{Test chapter}
\section{Test section}
\end{document}
For chapter titles you could additionally use the PGF/TikZ package. Following the link below you will find an example thet could help you to get started:
Fancy chapter headings with TikZ - TeXblog.
custom chapter and section
Thank you very much. It works like a charm. I have just one question. How can I increase the thickness of the line?
In addition, I tried out the code for *chapter*, its about 70-80% as I intend to be...
Code: Select all
\titleformat{\chapter}[block]
{\begin{picture}(330,200)} {%
\put(0,230){%
\makebox(0,0)[lb]{%
\colorbox[named]{Cerulean}{%
\begin{tabular}{c}%
\multirow{3}{*}{}%
\textit{\textcolor{white}{Chapter}}\\%
\\%
\Huge \textcolor{white}{\thechapter}%
\end{tabular}
}
}
}
\textcolor[named]{Cerulean}{\uppercase{%
\put(75,250){%
\parbox[t]{300pt}{%
\LARGE\filright #1
}
}
}}
}
{0pt}{}
[\end{picture}]
I was not able to figure out is how to change the font of the numbers below *chapter* even bigger.. Its already \Huge. Also, I would like the first letter to be bigger caps than the others (in word, this option is Small caps). I don't want to just increase the size of I to make the others look smaller.. I wonder if an option is there in latex to accomplish this?
Other than that, I think this looks good. Except, I wonder if the \parbox will disrupt the alignment with Chapter if the name of the chapter is too long...
I would appreciate if you have any suggestions in this regard, or any other suggestions.
Also, I noted that your code for \section changes the font and also draws a line for *Abstract* and *Acknowledgements* section of my thesis.
I would like to know how I could remove them (in case I don't want these options there) and also if/how to add similarly to reflect in Header, footer, table of contents etc...
I hope your code could be easily replaced for subsection too. If so, I don't have a problem there.
Thank you very much for your help. I would appreciate if you could give some pointers to my questions.
very best,
Arun.
- Attachments
-
- Chapter - Latex code
- chp1.jpg (17.91 KiB) Viewed 10982 times
custom chapter and section
You can use \titleformat and \titlespacing* as many times as you wish inside the body of your document to change the format. Have a look at the following example, that switches between the fancy and the standard format (as defined for the book document class) for sections:pozdrav wrote:...Also, I noted that your code for \section changes the font and also draws a line for *Abstract* and *Acknowledgements* section of my thesis.
I would like to know how I could remove them (in case I don't want these options there)...
Code: Select all
\documentclass{book}
\usepackage[x11names]{xcolor}
\usepackage[explicit]{titlesec}
\titleformat{\section}[block]
{\normalfont\sffamily}
{\colorbox{blue!70}{\parbox[c][15pt][c]{30pt}{%
\hfil\color{white}\Large\thesection\hfil}}}
{0pt}
{\parbox{\linewidth}{%
\hspace*{1em}\color{DeepSkyBlue2}\large\sffamily#1\\[-8pt]\color{DeepSkyBlue2}\titlerule}}
\titlespacing*{\section}
{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\begin{document}
\chapter{Test chapter}
\section{Test section with a fancy title}
\titleformat{\section}
{\normalfont\Large\bfseries}{\thesection\ #1}{1em}{}
\titlespacing*{\section}
{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\section{Test section with a normal title}
\titleformat{\section}[block]
{\normalfont\sffamily}
{\colorbox{blue!70}{\parbox[c][15pt][c]{30pt}{%
\hfil\color{white}\Large\thesection\hfil}}}
{0pt}
{\parbox{\linewidth}{%
\hspace*{1em}\color{DeepSkyBlue2}\large\sffamily#1\\[-8pt]\color{DeepSkyBlue2}\titlerule}}
\titlespacing*{\section}
{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\section{Another test section with a fancy title}
\titleformat{\section}
{\normalfont\Large\bfseries}{\thesection\ #1}{1em}{}
\titlespacing*{\section}
{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\section{Another test section with a normal title}
\end{document}
Using the \fontsize command you can increase the font size:pozdrav wrote:...I was not able to figure out is how to change the font of the numbers below *chapter* even bigger.. Its already \Huge...
Code: Select all
\documentclass{book}
\usepackage{fix-cm}
\begin{document}
text text {\fontsize{40}{48}\selectfont text text} text text
\end{document}
Code: Select all
\documentclass{book}
\begin{document}
text text {\scshape Text text} text text
\end{document}
Re: custom chapter and section
I guess I have fixed everything I have in mind now. In case I run into any other problems, I will post again

I was able to fix the linewidth under section by just using \titlerule[1pt]
best, Arun.