I'm using \setcounter{secnumdepth}{0}
to show sections without any number. It works as expected, but I'd like to have some indentation to align the begin of the text.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\usepackage{blindtext}
\usepackage{filecontents}
\begin{filecontents}{text1.tex}
\section{text 1}
\blindtext
\end{filecontents}
\begin{filecontents}{text2.tex}
\section{text 2}
\blindtext
\end{filecontents}
\begin{filecontents}{text3.tex}
\section{text 3}
\blindtext
\end{filecontents}
\begin{filecontents}{text4.tex}
\section{text 4}
\blindtext
\end{filecontents}
\newcommand{\inputa}[1]{%
\setcounter{secnumdepth}{0}
\input{#1}
\setcounter{secnumdepth}{1}
}
\begin{document}
\input{text1.tex}
\inputa{text2.tex}
\input{text3.tex}
\input{text4.tex}
\tableofcontents
\end{document}
I'd like all the words "text" to be aligned.
[EDIT after Phelype Oleinik answere]
Regarding the suggested non-starred approach: I will not manually change my numerous sections consisting of a lot of different .tex files. I've once tried to make it automated writing my \inputa
command with something like:
\newcounter{starlab}%counter for a label to use with \nameref
\newcommand{\inputa}[1]{%
\let\origsection\section
\renewcommand{\section}{% force starred section
\@ifstar{\origsection*}{\origsection*}}
\input{#1}
\refstepcounter{starlab}\label{sec:\thestarlab}
\addcontentsline{toc}{section}{\protect\numberline{}\nameref{sec:\thestarlab}}
\let\orgisection\section
}
But…
- I cannot compile it anymore, I don't know why (
Argument of \@ssect has an extra }
error). - yersterday it worked on my document with the desired appearance, but I still had a problem with
hypperef
since the label points at the end of the text, and those texts are sometimes quite long.