3

I would like to format the section like seen below. enter image description here I started with these codes.

\documentclass[openany]{book}
\usepackage{titlesec,xcolor}
\usepackage{mathspec}
\titleformat{\section}{\Large\fontspec{ITC Berkeley Oldstyle 
Std}}{\textcolor{black}{\rule[-15pt]{15pt}{2em}}~\rule[-
15pt]{2pt}{2em}}{10pt}{{\fontspec{Chevin}\textbf{TOPIC- \thesection}}\\[- 
2ex]}
\begin{document}
\chapter{Physical Equilibria} 
\setcounter{section}{1}
\section{Raoult's law, Ideal and Non-ideal Solutions} 
\end{document}

Compiling it gave me the image below.

enter image description here

Which is far from what I desire. Thanks in advance for any kind help

2 Answers 2

2

In fontawesome5 package you can find a pen nib. About other fonts, I cannot help.

\documentclass{article}
\usepackage{titlesec,xcolor}
\usepackage{fontawesome5}
\usepackage{graphicx}
\usepackage{mathspec}

\titleformat{\section}{\Large\fontspec{ITC Berkeley Oldstyle 
Std}}{\colorbox{black}{\rotatebox{135}{\color{white}{\faPenNib}}}\quad\rule[-
15pt]{2pt}{2em}}{10pt}{{\fontspec{Chevin}\textbf{TOPIC- \thesection}}\\[- 
2ex]}

\begin{document}

\setcounter{section}{1}
\section{Raoult's law, Ideal and Non-ideal Solutions} 

\end{document}

enter image description here

1

This doesn't really add much to @Ignasi's answer, but you could declare \section as a display heading (like a chapter), which makes it slightly easier to lay out TOPIC and the section name.

I also pointlessly used expl3 coffins so things would line up without me having to do any thinking. There are absolutely better ways of doing this…

\documentclass{book}

\usepackage{titlesec}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{fontawesome5}

\ExplSyntaxOn
\dim_const:Nn \c__kidegalize_section_ht_dim { 30 pt }
\coffin_new:N \l__kidegalize_nib_coffin
\coffin_new:N \l__kidegalize_section_coffin
\hcoffin_set:Nn \l__kidegalize_nib_coffin
  {
    \color_select:n { white }
    \LARGE
    \faPenNib
  }
\coffin_rotate:Nn \l__kidegalize_nib_coffin { 135 }
\hcoffin_set:Nn \l__kidegalize_section_coffin
  {
    \color_select:n { black!50 }
    \rule { \c__kidegalize_section_ht_dim } { \c__kidegalize_section_ht_dim }
    \skip_horizontal:n { \c__kidegalize_section_ht_dim / 3 }
    \rule { 2pt } { \c__kidegalize_section_ht_dim }
    \skip_horizontal:n { \c__kidegalize_section_ht_dim / 3 }
  }
\coffin_attach:NnnNnnnn
  \l__kidegalize_section_coffin { hc } { vc }
  \l__kidegalize_nib_coffin { hc } { vc }
  { -\c__kidegalize_section_ht_dim / 3 - 1pt } { 0pt }
\coffin_resize:Nnn \l__kidegalize_section_coffin
  { \coffin_wd:N \l__kidegalize_section_coffin } { 0pt }
\NewDocumentCommand \nib { }
  {
    \coffin_typeset:Nnnnn \l__kidegalize_section_coffin
      { r } { b } { 0pt } { 0pt }
  }
\dim_const:Nn \nibwidth { \coffin_wd:N \l__kidegalize_section_coffin }
\ExplSyntaxOff

\titleformat{\section}[display]
  {\normalfont\Large\sffamily\bfseries}
  {TOPIC-\thesection}
  {0pt}
  {\nib\normalfont\large\sffamily\color{black!50}}
\titlespacing*{\section}{\nibwidth}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}

\begin{document}
\setcounter{chapter}{1}
\setcounter{section}{1}
\section{Raoult's law, Ideal and Non-ideal Solutions} 
\end{document}

output

You must log in to answer this question.

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