1

I'm trying to make a document that needs to be structured with 5 sublevels, where every single sentence in the document needs to have a label in front of it such as 1.2.4 or 1.4.5.6.4. What is the best approach to doing this (I know it doesn't look great but it is what I need). Also, I would like to keep control over each level to the extent shown in the sample code.

What I have done is use the article document class and format paragraph and subparagraph to essentially give me subsubsubsection and subsubsubsubsection.

Is there another way to do this? As of right now the entire document has no text, only section headings, which appears as I want it to but I was wondering if there is a better method.

\documentclass[letterpaper]{article}

\usepackage{titlesec} 
\titleformat{\section}
{\normalfont\fontfamily{phv}\fontsize{13}{16}\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}
{\normalfont\fontfamily{phv}\fontsize{12}{14}\selectfont}{\thesubsection}{1em}{}
\titleformat{\subsubsection}
{\normalfont\fontfamily{phv}\fontsize{12}{14}\selectfont}{\thesubsubsection}{1em}{}

\setcounter{secnumdepth}{5}
\titleformat{\paragraph}
{\normalfont\fontfamily{phv}\fontsize{12}{14}\selectfont}{\theparagraph}{1em}{}
\titleformat{\subparagraph}
{\normalfont\fontfamily{phv}\fontsize{12}{14}\selectfont}{\thesubparagraph}{1em}{}

\titlespacing*{\section}{0pt}{1.5ex}{1.5ex}
\titlespacing*{\subsection}{30pt}{1.5ex}{1.5ex}
\titlespacing*{\subsubsection}{60pt}{1.5ex}{1.5ex}
\titlespacing*{\paragraph}{100pt}{1.5ex}{1.5ex}
\titlespacing*{\subparagraph}{120pt}{1.5ex}{1.5ex}


\begin{document}

\section{Hello}
\subsection{Hello}
\subsubsection{Hey There}
\paragraph{Yes sir}
\subparagraph{Good morning}

\end{document}

Edited to show current state: enter image description here

\documentclass{article}

\newcounter{depth}
\setcounter{depth}{1}
\newcounter{pi}
\newcounter{pii} [pi]  \renewcommand\thepii{\thepi.\arabic{pii}}
\newcounter{piii}[pii] \renewcommand\thepiii{\thepii.\arabic{piii}}
\newcounter{piv} [piii]\renewcommand\thepiv{\thepiii.\arabic{piv}}
\newcounter{pv}  [piv] \renewcommand\thepv{\thepiv.\arabic{pv}}


\def\psetdepth#1#2\relax{%
\ifx+#1\relax\addtocounter{depth}{#2}%
\else\ifx-#1\relax\addtocounter{depth}{-#2}%
\else\setcounter{depth}{#1#2}\fi\fi}

\newcommand\sentence[2][+0]{%
  \par
  \psetdepth#1\relax\relax
  \vspace{\csname pspace\roman{depth}\endcsname}%
  \hspace{\csname phspace\roman{depth}\endcsname}%
  \hangindent=\csname pindent\roman{depth}\endcsname
  \hangafter=1
  \indent\refstepcounter{p\roman{depth}}\llap{\csname thep\roman{depth}\endcsname\ }%
  {\csname pstyle\roman{depth}\endcsname#2\par}}

\newcommand\phspacei{20pt}
\newcommand\phspaceii{40pt}
\newcommand\phspaceiii{65pt}
\newcommand\phspaceiv{100pt}
\newcommand\phspacev{140pt}

\newcommand\pindenti{5ex}
\newcommand\pindentii{10ex}
\newcommand\pindentiii{15ex}
\newcommand\pindentiv{23.5ex}
\newcommand\pindentv{32.5ex}

\newcommand\pspacei{15pt}
\newcommand\pspaceii{15pt}
\newcommand\pspaceiii{10pt}
\newcommand\pspaceiv{10pt}
\newcommand\pspacev{10pt}

\newcommand\pstylei{\Large\bfseries}
\newcommand\pstyleii{\bfseries\itshape}
\newcommand\pstyleiii{\normalfont}
\newcommand\pstyleiv{\normalfont}
\newcommand\pstylev{\normalfont}

\begin{document}
\raggedright

\sentence{This is a sentence.}

\sentence{This is another sentence. Just like any other sentence one would think but perhaps not.}


\sentence[+1]{This sentence is similar to the others, but longer. This sentence is similar to the others, but longer.This sentence is similar to the others, but longer.}


\sentence{This is a sentence.This sentence is similar to the others, but longer.This sentence is similar to the others, but longer.This sentence is similar to the others, but longer.}


\sentence[+1]{This is another sentence.This sentence is similar to the others, but longer.This sentence is similar to the others, but longer.This sentence is similar to the others, but longer.}


\sentence[+1]{This sentence is similar to the others, but longer.This sentence is similar to the others, but longer.This sentence is similar to the others, but longer.This sentence is similar to the others, but longer.}


\sentence{This is a sentence.This sentence is similar to the others, but longer.This sentence is similar to the others, but longer.This sentence is similar to the others, but longer.}

\sentence{This is another sentence.This sentence is similar to the others, but longer.This sentence is similar to the others, but longer.This sentence is similar to the others, but longer.}

\sentence{This sentence is similar to the others, but longer.}

\sentence[+1]{Hey there how is it going my good friend. Hey there how is it going my good friend.}

\sentence[-2]{This is a sentence hey.}

\sentence{This is another sentence.}

\sentence{This sentence is similar to the others, but longer.}

\sentence[-1]{This is a sentence.}

\end{document}
8
  • You could have a look at KOMA-script scrjura package: it is initially intended for documents such as contracts or laws, but... a document "where every single sentence in the document needs to have a label in front of it" looks pretty much like a contract or a law, right?
    – ebosi
    Commented Apr 7, 2017 at 19:41
  • To Christian, sorry I'm not sure I understand. I'm not looking for more levels of depth. Ebo yeah, I will take a look at that package.
    – Elijah
    Commented Apr 7, 2017 at 19:45
  • Why not nested enumerate environments, with convenient list parameters?
    – Bernard
    Commented Apr 7, 2017 at 19:46
  • @Elijah: Misread your question. But I don't recommend such labelling at all.
    – user31729
    Commented Apr 7, 2017 at 19:48
  • Haha nor would I, but it is required for what I'm doing unfortunately
    – Elijah
    Commented Apr 7, 2017 at 19:49

1 Answer 1

4

If you are aiming for a minimal scheme with essentially just numbered sentences with minimal formatting, you can have very minimal markup in the document.

enter image description here

\documentclass{article}

\newcounter{depth}
\setcounter{depth}{1}
\newcounter{pi}
\newcounter{pii} [pi]  \renewcommand\thepii{\thepi.\arabic{pii}}
\newcounter{piii}[pii] \renewcommand\thepiii{\thepii.\arabic{piii}}
\newcounter{piv} [piii]\renewcommand\thepiv{\thepiii.\arabic{piv}}
\newcounter{pv}  [piv] \renewcommand\thepv{\thepiv.\arabic{pv}}
\newcommand\pdown{\addtocounter{depth}{1}\setcounter{p\roman{depth}}{0}}
\newcommand\pup{\addtocounter{depth}{-1}}
\makeatletter
\begin{document}


\everypar{%
\refstepcounter{p\roman{depth}}\llap{\csname thep\roman{depth}\endcsname\ }}




This is a sentence.

This is another sentence.

\pdown
This sentence is similar to the others, but longer.


This is a sentence.

\pdown
This is another sentence.

\pdown
This sentence is similar to the others, but longer.


This is a sentence.

This is another sentence.

This sentence is similar to the others, but longer.

\pup
\pup
This is a sentence.

This is another sentence.

This sentence is similar to the others, but longer.

\pup
This is a sentence.

\pdown
This is another sentence.

This sentence is similar to the others, but longer.


This is a sentence.

\pdown
This is another sentence.

This sentence is similar to the others, but longer.


This is a sentence.

This is another sentence.

\pup
This sentence is similar to the others, but longer.

\pdown
This is a sentence.

This is another sentence.

\pup\pup
This sentence is similar to the others, but longer.


This is a sentence.

\pdown
This is another sentence.

This sentence is similar to the others, but longer.


\end{document}

If you want customisable fonts and spacing I would use a scheme more like the following. You can move a sentence up or down a level with relative values such as [+1] or [-1] or jump to a specific level such as [1] to get back to a top level. You can specify a vertical space command an a font (or colour or whatever) command at each level.

enter image description here

\documentclass{article}

\newcounter{depth}
\setcounter{depth}{1}
\newcounter{pi}
\newcounter{pii} [pi]  \renewcommand\thepii{\thepi.\arabic{pii}}
\newcounter{piii}[pii] \renewcommand\thepiii{\thepii.\arabic{piii}}
\newcounter{piv} [piii]\renewcommand\thepiv{\thepiii.\arabic{piv}}
\newcounter{pv}  [piv] \renewcommand\thepv{\thepiv.\arabic{pv}}


\def\psetdepth#1#2\relax{%
\ifx+#1\relax\addtocounter{depth}{#2}%
\else\ifx-#1\relax\addtocounter{depth}{-#2}%
\else\setcounter{depth}{#1#2}\fi\fi}

\newcommand\sentence[2][+0]{%
  \par
  \psetdepth#1\relax\relax
  \vspace{\csname pspace\roman{depth}\endcsname}%
  \indent\refstepcounter{p\roman{depth}}\llap{\csname thep\roman{depth}\endcsname\ }%
  {\csname pstyle\roman{depth}\endcsname#2\par}}


\newcommand\pspacei{\baselineskip}
\newcommand\pspaceii{.5\baselineskip}
\newcommand\pspaceiii{.5\baselineskip}
\newcommand\pspaceiv{0pt}
\newcommand\pspacev{0pt}

\newcommand\pstylei{\Large\bfseries}
\newcommand\pstyleii{\bfseries\itshape}
\newcommand\pstyleiii{\normalfont}
\newcommand\pstyleiv{\normalfont}
\newcommand\pstylev{\normalfont}

\begin{document}
\raggedright





\sentence{This is a sentence.}

\sentence{This is another sentence.}


\sentence[+1]{This sentence is similar to the others, but longer.}


\sentence{This is a sentence.}


\sentence[+1]{This is another sentence.}


\sentence[+1]{This sentence is similar to the others, but longer.}


\sentence{This is a sentence.}

\sentence{This is another sentence.}

\sentence{This sentence is similar to the others, but longer.}

\sentence[-2]{This is a sentence.}

\sentence{This is another sentence.}

\sentence{This sentence is similar to the others, but longer.}

\sentence[-1]{This is a sentence.}


\sentence[+1]{This is another sentence.}

\sentence{This sentence is similar to the others, but longer.}


\sentence{This is a sentence.}


\sentence[+1]{This is another sentence.}

\sentence{This sentence is similar to the others, but longer.}


\sentence{This is a sentence.}

\sentence{This is another sentence.}

\sentence[-1]{This sentence is similar to the others, but longer.}


\sentence[+1]{This is a sentence.}

\sentence{This is another sentence.}

\sentence[-2]{This sentence is similar to the others, but longer.}


\sentence{This is a sentence.}


\sentence[+1]{This is another sentence.}

\sentence{This sentence is similar to the others, but longer.}


\end{document}
7
  • That is awesome. Also sorry about that, this is my first post. I attached a sample code to my question above. Is there anyway using the method you just wrote to control specific levels of depth in the same way that I was doing using \titleformat and \titlespacing?
    – Elijah
    Commented Apr 7, 2017 at 20:51
  • @Elijah yes or no... I went for this very minimal markup as I thought you were aiming for more or less plain text but with numbered sentences. if you want font and spacing changes I would use a syntax that has the text in a command argument \anything{....} as that makes it clearer and much easier to define. Once you have that markup there is no need to use the \everypar trick to automatically add the numbering. so the answer becomes more or less completely different:-) I may post a version later but I'll leave it a bit, see if someone else wants to post an answer in a different style. Commented Apr 7, 2017 at 20:59
  • I would very much appreciate that as I'm not entirely sure what you mean
    – Elijah
    Commented Apr 8, 2017 at 0:21
  • @Elijah answer updated Commented Apr 8, 2017 at 10:17
  • horizontal space? also for any latex counter \thexxx is supposed to print its value, if you redefine \thepii as in your comment every line will be labeled with a length instead of the counter?? Commented Apr 8, 2017 at 18:08

You must log in to answer this question.

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