1

I was wondering if anyone would know how I can modify the general style that has the latex document so that the section part, subsection and subsubsection follow the specifications that I show in the following image.

enter image description here

At the moment what I was doing with the section and subsection part was something like this:

\section{\underline{THIS IS THE SECTION TITLE}}
\subsection{\textit{This is the subsection title}}

For the subsubsection part using times new roman as far as I could read it is not possible to use small caps, so capital letters would do.

----- TEMPLATE.

\documentclass[a4paper,12pt]{exam}

% PAQUETES PRINCIPALES % ---------------------------------------------------------------------------------------- % ---------------------------------------------------------------------------------------- \usepackage[bitstream-charter]{mathdesign} % Paquete de fuentes matemáticas. \usepackage[spanish, es-tabla]{babel} % Paquete de caracteres y títulos en español \usepackage[utf8]{inputenc} % Permite escribir con acentos. \usepackage{newtxtext,newtxmath} % Permite cambiar el tipo de letra a Times New Roman \usepackage{lipsum} % Permite añadir texto LIPSUM.

\usepackage{ragged2e} % Paquete de alineación del texto. \usepackage{amsmath} % Paquete para insertar símbolos matemáticos \usepackage{hyperref} % Paquete para insertar referencias en el texto \hypersetup{ % Establecer las propiedades para las referencias.
colorlinks = true, linkcolor = matlab_blue, urlcolor = matlab_blue, citecolor = matlab_blue } \usepackage{textcomp,gensymb} % Paquetes que permiten agregar símbolos al texto. \usepackage{float} % Paquete para tratar figuras y tablas como flotantes \usepackage{lipsum} % Paquete para insertar texto mudo \usepackage[none]{hyphenat} % Eliminar la división de palabras en el texto. \setlength{\parindent}{0pt} % Permite definir el símbolo de diámetro \usepackage{wasysym} \usepackage{enumitem}

% PAQUETES PARA LA DEFINICIÓN DE COLORES. % ---------------------------------------------------------------------------------------- % ---------------------------------------------------------------------------------------- \usepackage[dvipsnames,table,xcdraw]{xcolor} \definecolor{airforceblue}{rgb}{0.36, 0.54, 0.66} \definecolor{matlab_blue}{rgb}{0, 0.447 0.741}

% MODIFICAR LA ZONA EN LA QUE SE INCUYE EL RESUMEN % ---------------------------------------------------------------------------------------- % ---------------------------------------------------------------------------------------- \renewenvironment{abstract} % Modifica la alineación del resumen. {\par\noindent\textbf{\abstractname}\ \ignorespaces \} {\par\noindent\medskip}

% PAQUETES PARA TRABAJAR CON FIGURAS. % ---------------------------------------------------------------------------------------- % ---------------------------------------------------------------------------------------- \usepackage{graphicx} % Paquete para insertar imágenes en latex. \graphicspath{ {images/} } % Ruta para buscar las imágenes. \usepackage{caption} % Modificaciones en el título de las figuras. \usepackage{subcaption} % Modificaciones independientes en los títulos.

% - Permite cambiar la numeración de las figuras para incluir el número de la sección % - y también cambia el estilo del texto \setcounter{figure}{0} \renewcommand{\thefigure}{\arabic{section}.\arabic{figure}} \captionsetup[figure]{labelfont={it},textfont=it,labelsep=period,font=small}

% - Permite cambiar la numeración de las tablas para incluir el número de la sección % - y también cambia el estilo del texto \renewcommand{\thetable}{\arabic{section}.\arabic{table}} \captionsetup[table]{labelfont={it},textfont=it,labelsep=period,font=small}

% - Código que permite eliminar la línea en blanco de forma previa a % - incluir una enumeración \setlist[itemize]{noitemsep, topsep=-12pt, after=\vspace{\baselineskip}}

\usepackage{array} \newenvironment{conditions} {\par\vspace{\abovedisplayskip}\noindent\begin{tabular}{>{$}l<{$} @{${}={}$} l}} {\end{tabular}\par\vspace{\belowdisplayskip}}

% ESTABLECER LOS MÁRGENES DEL DOCUMENTO % ---------------------------------------------------------------------------------------- % ---------------------------------------------------------------------------------------- \usepackage[a4paper,top=20mm,left=25mm,right=20mm,bottom=20mm,headheight=20mm]{geometry}

% CAMBIAR EL INTERLINEADO DEL DOCUMENTO % ---------------------------------------------------------------------------------------- % ---------------------------------------------------------------------------------------- \usepackage{setspace} \spacing{1}

% CREAR PÁGINAS EN BLANCO HASTA LLEGAR A PÁGINA PAR % ---------------------------------------------------------------------------------------- % ---------------------------------------------------------------------------------------- \usepackage{changepage,ifthen} \newcommand\skiptoevenpage{% \checkoddpage \ifthenelse{\boolean{oddpage}}% {\null\clearpage}% {\null\clearpage \null \clearpage}% }

% CREAR PÁGINAS EN BLANCO HASTA LLEGAR A PÁGINA IMPAR % ---------------------------------------------------------------------------------------- % ---------------------------------------------------------------------------------------- \newcommand\skiptooddpage{% \checkoddpage \ifthenelse{\boolean{oddpage}}% {\null\clearpage \null \clearpage}% {\null\clearpage}% }

% CREAR EL ENCABEZADO DEL DOCUMENTO % ---------------------------------------------------------------------------------------- % ---------------------------------------------------------------------------------------- \header{}{}{HEADER} \headrule

% ---------------------------------------------------------------------------------------- % ---------------------------------------------------------------------------------------- % ---------------------------------------------------------------------------------------- % ---------------------------------------------------------------------------------------- \begin{document} \sloppy

\section{\underline{THIS IS THE SECTION TITLE}} %% THIS IS WRONG!! \lipsum[2-4]

\textit{\subsection{\underline{This is the subsection title}}} %% THIS IS WRONG!! \lipsum[1]

\textit{\subsubsection{\underline{This is the subsubsection title}}} %% THIS IS WRONG!! \lipsum[1]

\end{document}

  • Friendly tip: Don't. Underlining is bad typography and more than problematic in TeX. If you absolutely have to, the best approach heavily depends on your document class and the used engine, so please provide a complete minimal example giving us a small document we can play with and also say whether you're using pdfLaTeX, LuaLaTeX or XeLaTeX. Regardless of what will come out of this question: What you're doing (using \underline or \textit inside \section) is wrong. – Skillmon Feb 13 '22 at 17:54
  • (Also, believe me, I know about what I'm talking, I maintain a document class which has to underline section headings) – Skillmon Feb 13 '22 at 17:57
  • Avoid adding local formation into your titles (section, subsection, etc). This answer might be helpful for you. It uses the package titlesec. – FHZ Feb 13 '22 at 18:39
  • Unfortunately it is something that I have to do in order to meet the needs of a certain staff... I modify the original post so you can see the basic template I am using. The compiler is pdfLaTex @Skillmon. Thanks for all – Alejandro Fernández Suárez Feb 13 '22 at 18:43
  • Yes, thank you @FHZ, it's useful for most of the parts except for the underlining of certain parts and a few other little things, but thank you very much! – Alejandro Fernández Suárez Feb 13 '22 at 18:54
  • You'd still need to modify things a bit, but take a look here: https://tex.stackexchange.com/questions/429441 and https://tex.stackexchange.com/questions/476173 – Skillmon Feb 15 '22 at 17:04

1 Answers1

0

The following defines your section format. I cleaned up your preamble a bit (removed everything unrelated to the section formatting).

Note that as soon as you load \usepackage[bitstream-charter]{mathdesign} the italic small caps won't work anymore. Do you really need that package? You also load newtxmath to change your math fonts.

\documentclass[a4paper,12pt]{exam}

% PAQUETES PRINCIPALES % ---------------------------------------------------------------------------------------- % ---------------------------------------------------------------------------------------- \usepackage[spanish, es-tabla]{babel} % Paquete de caracteres y títulos en español \usepackage{newtxtext,newtxmath} % Permite cambiar el tipo de letra a Times New Roman \usepackage{ragged2e}

\setlength{\parindent}{0pt}% BAD PRACTICE!

% ESTABLECER LOS MÁRGENES DEL DOCUMENTO % ---------------------------------------------------------------------------------------- % ---------------------------------------------------------------------------------------- \usepackage[a4paper,top=20mm,left=25mm,right=20mm,bottom=20mm,headheight=20mm]{geometry}

% stuff necessary for the headings \usepackage[explicit]{titlesec} \usepackage[normalem]{ulem} \usepackage{xfp} \newlength\TitleUnderlineSeg \setlength\TitleUnderlineSeg{.05pt} \newcommand\TitleUnderlineThickness{.15ex}% not a length to get re-evaluated \newcommand\TitleUnderline[1] {% \bgroup \markoverwith {% \rule [-.7ex] {\TitleUnderlineSeg} {\TitleUnderlineThickness}% }% \ULon{#1}% } \makeatletter \ExplSyntaxOn \cs_new_eq:NN \TextUppercase \text_uppercase:n \ExplSyntaxOff \newcommand\setuptitleformat[1] {% \expandafter\setuptitleformat@\csname #1\endcsname{#1}% } \newcommand\setuptitleformat@[7] {% \begingroup \edef\tmp {% \endgroup \unexpanded{\titleformat{#1}}% {% \noexpand\fontsize{#3pt}{\fpeval{1.6#3}pt}% \unexpanded{\raggedright\bfseries#7}% }% }% \tmp {\leavevmode\kern#4\csname the#2\endcsname.#5} {0pt} {\begingroup\edef\tmp{\endgroup\noexpand\TitleUnderline{#6}}\tmp}% \begingroup \edef\tmp {% \endgroup \unexpanded{\titleformat{name=#1,numberless}}% {% \noexpand\fontsize{#3pt}{\fpeval{1.6#3}pt}% \unexpanded{\raggedright\bfseries#7}% }% }% \tmp {} {0pt} {\begingroup\edef\tmp{\endgroup\noexpand\TitleUnderline{#6}}\tmp}% } % level size indent separation formatting \setuptitleformat{section} {18}{-.63cm}{ \space}{\TextUppercase{#1}}{} \setuptitleformat{subsection} {14} {0pt}{ } {\unexpanded{#1}} {\itshape} \setuptitleformat{subsubsection}{12} {0pt}{} {\unexpanded{#1}} {\itshape\scshape} % undefine the helper macros \let\setuptitleformat @undefined \let\setuptitleformat@@undefined \makeatother

\usepackage{lipsum} % dummy text

\begin{document}

\section{This is the section title}

\subsection{This is the subsection title}

\subsubsection{This is the subsubsection title}

\lipsum[1]

\section{Really long section title that is really long, so long it needs more than one line to be fully printed} \subsection{Really long subsection title that is really long, so long it needs more than one line to be fully printed} \subsubsection{Really long subsubsection title that is really long, so long it needs more than one line to be fully printed}

\section{Really long section title that is really long, so long it needs more than one line to be fully printed} \subsection{Really long subsection title that is really long, so long it needs more than one line to be fully printed} \subsubsection*{Really long subsubsection title that is really long, so long it needs more than one line to be fully printed}

\end{document}

enter image description here

Skillmon
  • 60,462