0

I would like to change the style of Paragraphs in LyX as follows:

  • They should be numbered, with sequential numbers in the entire document (regardless of sections, subsections etc.) starting from 1, 2, 3...
  • The numbers should be shown in the margin, with the title in the "normal" place in the body
  • They should be not indented.

The numbering of sections, subsections etc need not be changed. (I already add the word "Section" before the number using Adding text to the section numbering to avoid confusion.) I prefer not to use a list as this structure will continue for my entire document.

Something like this: (rough mockup in MS Word using a numbered list) enter image description here

Here is an example (the LaTeX exported from LyX). I would like the first section to have the number 1 (or "Section 1" etc) and the paragraphs to be numbered 1, 2 etc.

%% LyX 2.3.7 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\begin{document}

\section{The first section}

\paragraph{The heading of the first paragraph}

The content of the first paragraph shall be: \begin{enumerate} \item A list \item containing \item some items \end{enumerate}

\paragraph{The heading of the second paragraph}

The second paragraph contains no items but it has a lot of text like this. It goes on and on and on and on. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vel magna congue, suscipit ipsum et, cursus erat. Praesent lacus nisi, viverra in mauris eget, elementum viverra quam. \end{document}

noxewa
  • 65
  • Please provide code for a small document people can compile to test with (a Minimum Working Example). Why exactly do you want to avoid a list? You could potentially use \paragraph{}. This is not actually a command for making paragraphs but, rather, a sectioning command (sub-\subsubsection). Or \subparagraph{} (sub-sub-\subsubsection). The format you show is not paragraphs really. It is more like a list or a section. (That is, as these terms are usually used. I'm not saying what anything 'should' be called.) – cfr Nov 24 '23 at 18:50
  • Do you want the numbers to show up in the PDF output also? Or only in the LyX display? – scottkosty Nov 24 '23 at 19:21
  • @scottkosty: In the PDF output. I don't care about the LyX display. – noxewa Nov 25 '23 at 06:45
  • @cfr: I will edit to add the sample document. As for the use case and the reason why I want to avoid lists: I am basically trying to typeset something like a "rulebook" with numbered articles/paragraphs, for which \paragraph{} would be quite ideal, if they were numbered the way I wanted. I don't want to use "sections" because they are too high a level in the hierarchy and give a much bigger title than necessary. – noxewa Nov 25 '23 at 06:47
  • @noxewa I would look at some of the packages for law. Legal documents are full of numbered paragraphs. Otherwise, just customise the formatting of \paragraph numbers. Details depend on your class, but generally you just need to change the depth counter and alter the section number format. You could equally well use \section, if you don't need any actual sections. If you have actual sections, that's different. A list would be a bit less faff because, if you have sections, you'll need to mess with numbering-within, but it is just a question of tracking down all the loose ends. – cfr Nov 25 '23 at 07:00
  • @cfr Could you suggest some of the packages for law which are more generalised? I have looked at brlex and ukbill and both are highly inflexible and tailored to their own specific purposes. The first contains Portuguese text and neither does it have numbering in the margin, and the second is highly specific to proposed laws in the UK parliament, containing huge titles with the word "BILL" and enacting formulas and disclaimers that are required in the UK. – noxewa Nov 25 '23 at 07:05
  • Nah. I just know there's a bunch of packages for law. The only legal stuff I've used is bibliography support. I just use \marginpar or maybe a custom wrapper for numbering paragraphs when I need it. But I wouldn't format them like this. – cfr Nov 25 '23 at 07:19
  • @cfr - then, could you answer with the way you use marginpar or a custom wrapper? At least that may be of some use. – noxewa Nov 25 '23 at 07:36
  • I think the answer you have is better. My code isn't designed for this. You have headings. I'm just providing numbers for ease of reference. – cfr Nov 25 '23 at 16:35

1 Answers1

3

Like this?

enter image description here

\documentclass{article}
\usepackage{lipsum}
\usepackage{chngcntr}
\counterwithout{paragraph}{subsubsection}
\usepackage{titlesec}
\titleformat{\paragraph}[runin]{\bfseries}{\llap{\theparagraph\quad}}{0em}{}
\setcounter{secnumdepth}{4}
\begin{document}
\section{foo}
\paragraph{Lorem} \lipsum[1][1-4]
\paragraph{Nam} \lipsum[2][1-4]
\section{bar}
\paragraph{Nulla} \lipsum[3][1-4]
\paragraph{Quisque} \lipsum[4][1-4]
\end{document}

Note that you can do perfectly that in LyX, but you will see 1.0.0.1. Lorem in the LyX screen

Fran
  • 80,769
  • Thank you! In fact, the LyX screen simply doesn't show any numbers next to the paragraph, as I have not enabled the numbering of paragraphs in LyX itself, and evidently it doesn't detect that I did this through the "LaTeX Preamble" option. That is fine for me. – noxewa Nov 25 '23 at 12:01