In my project, I want to change fontsize for the subsection and subbsection (include their number) to the same size as what I write in the next line of its (I don't know how to say this in English naturally). How can I do it ? Thanks.
\documentclass[13pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[left=3cm,right=3cm,top=3cm,bottom=3cm]{geometry}
\usepackage{amsfonts}
\usepackage[titles]{tocloft}
\usepackage{sectsty}
% for the chapter
\renewcommand{\thechapter}{\arabic{chapter}.}
\newlength\mylength
\renewcommand\cftchappresnum{\large{\hspace{0.04cm}}}
\settowidth\mylength{\bfseries\cftchappresnum\cftchapaftersnum}
\addtolength\cftchapnumwidth{\mylength}
% for the section
\renewcommand{\thesection}{\arabic{chapter}.\arabic{section}}
\renewcommand{\cftsecnumwidth}{2em}
\sectionfont{\fontsize{17}{20}\selectfont}
% for the subsection
\renewcommand{\thesubsection}{\arabic{chapter}.\arabic{section}.\arabic{subsection}.\hspace{-.45cm} }
% for the subsubsection
\renewcommand{\thesubsubsection}{\arabic{chapter}.\arabic{section}.\arabic{subsection}.\arabic{subsubsection}\hspace{-.45cm} }
\begin{document}
\large{
\chapter{Knowledge}
\section{Algebra}
\subsection{Matrix.}
\subsection*{\Large{1.1.1. Matrix.} }
\subsubsection{Definition.}
\subsection*{1.1.1.1. Definition.}
}
\end{document}
\largeis a switch and doesn't take an argument. If you want to limit the scope of\large, you need to write{\large ...}, not\large{...}. – Mico Jan 09 '24 at 16:16sectstypackage, does thesectstyexample in that answer not work? – bonk Jan 09 '24 at 16:57sectsty, which you're already using in your example. Why not just use that solution? I had tested it out myself already and it definitely does work. – bonk Jan 09 '24 at 17:14