How to place \hspace{} before \section{} and \subsection{}? I am using an \documentclass[12pt, a4paper]{article}.
I want make custom command for \section{} and \subsection{} with different \hspace value. How to do it? Help!
Asked
Active
Viewed 83 times
0
Vladyslav Rehan
- 463
1 Answers
4
It is very hard to understand the question, which just has a fragment of code using an unshown package, and an undefined command, and nothing else. however I think you want this which just adds \hspace*{} to a copy of \section from article.cls
\documentclass{article}
\makeatletter
\newcommand\sectionx[1]{@startsection {section}{1}{\z@}%
{-3.5ex @plus -1ex @minus -.2ex}%
{2.3ex @plus.2ex}%
{\hspace*{#1}\normalfont\Large\bfseries}}
\makeatother
\begin{document}
\tableofcontents
\section{A section}
aaa
\sectionx{1cm}{Another section}
aaa
\sectionx{.5cm}{Yet another section}
aaa
\section{A final section}
aaa
\end{document}
David Carlisle
- 757,742

\RedeclareSectionCommand[? – David Carlisle Nov 05 '22 at 18:47mystyle. I just shown it because its been in famous ansver to my question already but it does not suit me. – Vladyslav Rehan Nov 05 '22 at 18:50mystyle, thanks for note. – Vladyslav Rehan Nov 05 '22 at 18:59