2

I would like to typeset regulations and laws in LaTeX. For that I would need a way to structure my document like this:

  1. Title
  2. Chapter
  3. Section
  4. [Subsection]
  5. Article

Is there any way I can override the sectioning commands that default (or KOMA-Script) classes provide? You can see an example of the structure I would like to achieve here: https://www.boe.es/buscar/pdf/2015/BOE-A-2015-10566-consolidado.pdf

Thanks!

  • I'm not familiar with legalese terminology for sectioning headers, but it sounds like the following correspondence can be made: LaTeX: part -- legal: Title; chapter -- Chapter; section -- Section; [what's with subsections?]; subsubsection -- Article. Is this interpretation roughly correct? – Mico May 27 '18 at 20:31
  • 1
    Yes! Subsections would be optional and that's why I put them in brackets, but I think it's a bit confusing. I think articles would be something more like paragraphs. The number of the article would be in line with the rest of the text. Still, there would be differences because there's no need for titles to be on different pages ¿like \parts are?. You can see more or less (it's in spanish but) what I would like to achieve on the link. – José María May 27 '18 at 20:35
  • Moreover, it would appear that Chapter numbers are reset each time there's a new Title and that Section numbers are reset each time there's a new Chapter. In contrast, the numbering of Articles appears to be ever-increasing throughout the document -- no resets at the start of Sections (or of Titles or Chapters), right? – Mico May 27 '18 at 20:38
  • Exactly! Article numbers should not reset but Chapter and Sections should. – José María May 27 '18 at 20:42
  • If you are happy with the size and formatting for \part, \chapter, \section and \subsection, just use, for example, \renewcommand{\partname}{Ttile} to change the names. Article will need a separate counter, etc. – John Kormylo May 28 '18 at 1:41
3

Here is a suggestion using class scrartcl:

\documentclass[english]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage{babel}
\newcaptionname{english}{\Titlename}{Title}
\newcaptionname{english}{\Chaptername}{Chapter}
\newcaptionname{english}{\Sectionname}{Section}
\newcaptionname{english}{\Subsectionname}{Subsection}
\newcaptionname{english}{\Articlename}{Article}

\renewcommand\raggedpart{\centering}
\renewcommand\raggedsection{\centering}

\newcommand\entryprefix[2]{%
  #1\ #2
}

\DeclareNewSectionCommand[
  style=part,
  level=\partnumdepth,
  tocbeforeskip=2.25em plus 1pt,
  tocindent=0pt,
  tocnumwidth=2.3em,
  tocdynnumwidth,
  tocentrynumberformat=\entryprefix{\Titlename}
]{Title}
\renewcommand\theTitle{\Roman{Title}}
\renewcommand\Titleformat{\Titlename~\theTitle\autodot}

\DeclareNewSectionCommand[
  style=part,
  level=0,
  counterwithin=Title,
  font=\LARGE,
  prefixfont=\Large,
  tocindent=1em,
  tocnumwidth=2.3em,
  tocdynnumwidth,
  tocentrynumberformat=\entryprefix{\Chaptername}
]{Chapter}
\renewcommand\theChapter{\Roman{Chapter}}
\renewcommand\Chapterformat{\Chaptername~\theChapter\autodot}

\RedeclareSectionCommand[
  counterwithin=Chapter,
  tocentryformat=\normalfont,
  tocbeforeskip=0pt plus .2pt,
  tocentryindent=2em,
  tocpagenumberformat=\normalfont,
  tocdynnumwidth,
  tocentrynumberformat=\entryprefix{\Sectionname},
    toclinefill=\TOCLineLeaderFill
]{section}
\renewcommand\thesection{\arabic{section}}
\renewcommand\sectionformat{\Sectionname~\thesection\autodot\enskip}

\RedeclareSectionCommand[
  tocentryindent=3em,
  tocdynnumwidth,
  tocentrynumberformat=\entryprefix{\Subsectionname}
]{subsection}

\renewcommand\thesubsection{\arabic{subsection}}
\renewcommand\subsectionformat{\Subsectionname~\thesubsection\autodot\enskip}

\DeclareNewSectionCommand[
  style=section,
  level=\subsubsectionnumdepth,
  beforeskip=3.25ex plus 1ex minus .2ex,
  afterskip= 1.5ex plus .2ex,
  indent=0pt,
  font=\mdseries\slshape,
  tocstyle=default,
  toclevel=\subsubsectiontocdepth,
  tocindent=4em,
  tocnumwidth=2.3em,
  tocdynnumwidth,
  tocentrynumberformat=\entryprefix{\Articlename}
]{Article}
\renewcommand\Articleformat{\Articlename~\theArticle\autodot\enskip}

\renewcommand\sectionlinesformat[4]{%
  \ifstr{#1}{Article}
    {\raggedright\textbf{\upshape#3}#4.}
    {#3#4}%
}


\usepackage{lipsum}
\usepackage{blindtext}
\begin{document}
\tableofcontents
\Title{Title level}
\Chapter{Chapter level}
\section{Section level}
\Article{An article}
\lipsum[1-3]
\Article{A second article}
\lipsum[4]
\section{Section level}
\subsection{A subsection}
\Article{An article}
\lipsum[1-3]
\subsection{Another subsection}
\Article{A second article}
\lipsum[4]
\Title{Title level}
\Chapter{Chapter level}
\section{Section level}
\Article{An article}
\lipsum[1-3]
\Article{Another article}
\lipsum[4]
\end{document}

enter image description here

  • Yeah, this looks great! However, I tried to reproduce the document with the code you provided and I get some errors, beginning with ! Class scrartcl Error: before part skip of \Title unknown. and I'm not sure why... There's not much info anywhere on that error. Any idea? – José María May 29 '18 at 7:32
  • Which KOMA-Script version do you use? The code in my answer needs at least version 3.24, current version on CTAN and in the TL 2018 and MiKTex is 3.25. – esdd May 29 '18 at 8:59
  • With versions 3.21, 3.22 or 3.23 you have to add something like beforeskip=4ex, afterskip=3ex to the declaration of both Title and Chapter. Additionally Title needs font=\huge,prefixfont=\Large. Note that versions 3.24 and 3.25 uses the settings of part as default values for new section commands with style=part. – esdd May 29 '18 at 9:04
  • I have version 3.23, maybe I should try to update TexLive. But your workaround works perfectly! Thank you! This is what I wanted! What would be the benefits of using scrjura? – José María May 29 '18 at 11:17
  • If I change english to spanish on newcaptionname and translate the appropiate strings, the word "Article (Artículo in spanish) disappears on every line an article starts. Any ideas? – José María May 29 '18 at 13:53
3

pic of act

Based on the solution of esdd, I suggest to use the scrjura package for typesetting legal texts. My code is mostly stolen from Elkes solution, I only changed it on the level of Artículo and changed the language, because we have to provide the caption names for Artículos.

\documentclass[spanish, juratotoc=true, toc=flat]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{scrjura, libertine}
\newcaptionname{spanish}{\Titlename}{TÍTULO}
\newcaptionname{spanish}{\Chaptername}{CAPÍTULO}
\newcaptionname{spanish}{\Sectionname}{Sección}
\newcaptionname{spanish}{\Subsectionname}{Subsección}
%\newcaptionname{english}{\Articlename}{Article}

\providecaptionname{spanish}{\parname}{Artículo}
\providecaptionname{spanish}{\parshortname}{Art.}

\renewcommand{\Clauseformat}[1]{Artículo~#1.}
\setkomafont{contract.Clause}{\itshape{}}

\renewcommand\raggedpart{\centering}
\renewcommand\raggedsection{\centering}

\newcommand\entryprefix[2]{%
  #1\ #2
}

\DeclareNewSectionCommand[
  style=part,
  level=\partnumdepth,
  tocbeforeskip=2.25em plus 1pt,
  tocindent=0pt,
  tocnumwidth=2.3em,
  tocdynnumwidth,
  tocentrynumberformat=\entryprefix{\Titlename}
]{Title}
\renewcommand\theTitle{\Roman{Title}}
\renewcommand\Titleformat{\Titlename~\theTitle\autodot}

\DeclareNewSectionCommand[
  style=part,
  level=0,
  counterwithin=Title,
  font=\LARGE,
  prefixfont=\Large,
  tocindent=1em,
  tocnumwidth=2.3em,
  tocdynnumwidth,
  tocentrynumberformat=\entryprefix{\Chaptername}
]{Chapter}
\renewcommand\theChapter{\Roman{Chapter}}
\renewcommand\Chapterformat{\Chaptername~\theChapter\autodot}

\RedeclareSectionCommand[
  counterwithin=Chapter,
  tocentryformat=\normalfont,
  tocbeforeskip=0pt plus .2pt,
  tocentryindent=2em,
  tocpagenumberformat=\normalfont,
  tocdynnumwidth,
  tocentrynumberformat=\entryprefix{\Sectionname},
    toclinefill=\TOCLineLeaderFill
]{section}
\renewcommand\thesection{\arabic{section}}
\renewcommand\sectionformat{\Sectionname~\thesection\autodot\enskip}

\RedeclareSectionCommand[
  tocentryindent=3em,
  tocdynnumwidth,
  tocentrynumberformat=\entryprefix{\Subsectionname}
]{subsection}

\renewcommand\thesubsection{\arabic{subsection}}
\renewcommand\subsectionformat{\Subsectionname~\thesubsection\autodot\enskip}

% \DeclareNewSectionCommand[
%   style=section,
%   level=\subsubsectionnumdepth,
%   beforeskip=3.25ex plus 1ex minus .2ex,
%   afterskip= 1.5ex plus .2ex,
%   indent=0pt,
%   font=\mdseries\slshape,
%   tocstyle=default,
%   toclevel=\subsubsectiontocdepth,
%   tocindent=4em,
%   tocnumwidth=2.3em,
%   tocdynnumwidth,
%   tocentrynumberformat=\entryprefix{\Articlename}
% ]{Article}
% \renewcommand\Articleformat{\Articlename~\theArticle\autodot\enskip}

% \renewcommand\sectionlinesformat[4]{%
%   \ifstr{#1}{Article}
%     {\raggedright\textbf{\upshape#3}#4.}
%     {#3#4}%
% }




\usepackage{lipsum}
\usepackage{blindtext}
\begin{document}
\tableofcontents
\Title{Title level}
\Chapter{Chapter level}
\section{Section level}
\begin{contract}
  \Clause{title=Objeto.}
\label{CLA:objeto}
 La potestad sancionadora de las Administraciones Públicas se ejercerá cuando haya 
 sido  expresamente  reconocida  por  una  norma  con  rango  de  Ley,\dots

  El  ejercicio  de  la  potestad  sancionadora  corresponde\dots

\Clause{title=Ámbito Subjetivo}
\label{CLA:ambito-subjetivo}

Las  disposiciones  de  este  Capítulo  serán  extensivas  al  ejercicio  por  las 
Administraciones Públicas de su potestad disciplinaria

Las  disposiciones  de  este  capítulo  no  serán  de  aplicación  al  ejercicio  por  las 
Administraciones  Públicas  de  la  potestad


\end{contract}

\section{Section level}
\subsection{A subsection}
\begin{contract}
  \Clause{title=Principios generales}
\label{CLA:principios-generales}

La potestad sancionadora de las Administraciones Públicas se ejercerá cuando haya 
 sido  expresamente  reconocida  por  una  norma  con  rango  de  Ley,\dots

  El  ejercicio  de  la  potestad  sancionadora  corresponde\dots

Las  disposiciones  de  este  Capítulo  serán  extensivas  al  ejercicio  por  las 
Administraciones Públicas de su potestad disciplinaria

Las  disposiciones  de  este  capítulo  no  serán  de  aplicación  al  ejercicio  por  las 
Administraciones  Públicas  de  la  potestad


\Clause{title={Principios de intervención de las Administraciones Públicas para el desarrollo de 
una actividad.}, tocentry={Principios de intervención}}
\label{CLA:titl-de-interv}

La potestad sancionadora de las Administraciones Públicas se ejercerá cuando haya 
 sido  expresamente  reconocida  por  una  norma  con  rango  de  Ley,\dots

  El  ejercicio  de  la  potestad  sancionadora  corresponde\dots

Las  disposiciones  de  este  Capítulo  serán  extensivas  al  ejercicio  por  las 
Administraciones Públicas de su potestad disciplinaria

Las  disposiciones  de  este  capítulo  no  serán  de  aplicación  al  ejercicio  por  las 
Administraciones  Públicas  de  la  potestad




\end{contract}

\end{document}
  • The Artículo numbers in TOC are followed by two dots. You have to disable either \autodot for these TOC entries (eg. \DeclareTOCStyleEntry[...,entryformat=\let\autodot\relax]{default}{cpar}) or the dot in \Clauseformat within TOC (eg. \newcommand*\Clausedot{.} \renewcommand{\Clauseformat}[1]{Artículo~#1\Clausedot} and \AfterTOCHead[toc]{\renewcommand*\Clausedot\relax}). – esdd May 28 '18 at 14:15
  • @esdd Yes, there is plenty room for improvement. I expect OP to ask for changes of the par-counter »(1)« and much more. I did not look into the references according to spanish law and so on. But I'd be glad if he used scrjura for his purposes. – Keks Dose May 28 '18 at 14:21
  • I also believe that using scrjura is very useful here. – esdd May 28 '18 at 14:45
  • Oh, yeah, this looks really nice too! However I'm having the same problem I told @esdd, ! Class scrartcl Error: before part skip of \Title unknown.. I don't know if it's I'm copying something wrong (I tried exactly what you typed there), or maybe my LaTeX setup is outdated? I don't know. – José María May 29 '18 at 7:41
  • Another question, what are the benefits of using scrjura? It sounds interesting... Thanks! – José María May 29 '18 at 7:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.