1

I am looking for a way to place a simple "margin" note right beside the start of a paragraph in a two-column text. As it is right now, it just appears at either the left or right margin.

The note is just a number separated from the text, because otherwise it messes up the separation of words in a line (which matters in the text I am working on, not in the example below).

See this sample code below (see what I'm looking for in the image):

\documentclass[10pt]{article}
\usepackage{lipsum}
\usepackage{marginnote}
\usepackage{multicol}
\setlength{\columnsep}{10mm}

\begin{document}

\setlength\parindent{0em}
\setlength{\parskip}{1em}

\begin{multicols*}{2}

\reversemarginpar

\marginnote{1.} \lipsum[1]

\marginnote{2.} \lipsum[1]

\marginnote{3.} \lipsum[1]

\end{multicols*}

\end{document}

Move the number 3. over to the start of right paragraph, between the columns.

  • If you are happy with the 3 appearing in the right margin (instead of between the two columns), you can use the answers to this question. – Willie Wong Nov 22 '19 at 21:08
  • Or a slightly more automated version here – Willie Wong Nov 22 '19 at 21:13
  • No. My intention was to have the three right beside the beginning line of each new paragraph, to the left. In this case, the 1. left of the first Lorem; the 2. left of the second Lorem; and the 3. left of the third Lorem, and between columns. – Joel Dacasa Nov 22 '19 at 21:14
  • Is the note always a number? (So not very wide?) Instead of \marginpar{3. }..., try \leavevmode\llap{3. }\lipsum[1]. (For more of the same, see https://tex.stackexchange.com/questions/7865/how-to-create-hanging-bullet ) – Willie Wong Nov 22 '19 at 21:21
  • If the numbering is always consecutive, you can also use titlesec to number the paragraphs with paragraph numbers that hangs to the left. – Willie Wong Nov 22 '19 at 21:22
  • Perfect! The titlesec package has worked, and for anyone interested I will be posting here the solution to this issue. – Joel Dacasa Nov 22 '19 at 21:41

2 Answers2

2

Here's one solution, achieved by \llaping a string of numbers so that they hang out to the left of the paragraph.

\documentclass[10pt]{article}
\usepackage{lipsum}
\usepackage{multicol}
\setlength{\columnsep}{10mm}

\newcounter{parnum}
\newcommand*\NumPar{\refstepcounter{parnum}\leavevmode\llap{\arabic{parnum}. }}

\begin{document}

\setlength\parindent{0em}
\setlength{\parskip}{1em}

\begin{multicols*}{2}

\NumPar \lipsum[1-2]

\NumPar \lipsum[3]

\lipsum[4]

\NumPar \lipsum[5]

\end{multicols*}

\end{document}
Willie Wong
  • 24,733
  • 8
  • 74
  • 106
  • Works very well, too, and does not require using an additional package like I ended up using in my solution (thanks to your suggestion). Thanks! – Joel Dacasa Nov 22 '19 at 21:49
  • I just tried your implementation in my document, and it's perfect. However, is there a way to make the paragraph label/counter reset at the start of every \section? I would prefer to avoid a carry-over from the last one, if possible. – Joel Dacasa Nov 22 '19 at 21:57
  • 1
    You can use the \counterwithin command, like so: \counterwithin{parnum}{section}. This command is available in newer TeX engines; for older releases you may need to load the chngcntr package. – Willie Wong Nov 25 '19 at 14:24
  • 1
    (Incidentally, since I called \refstepcounter to increment the markers, you can also use \label and \ref to refer to them as usual.) – Willie Wong Nov 25 '19 at 14:26
  • Where would you put that command, then? First define \newcounter{parnum} and then write \counterwithin{parnum}{section} the line below? – Joel Dacasa Nov 25 '19 at 16:30
  • Yes, I'd put it there. – Willie Wong Nov 25 '19 at 16:31
1

Thanks to user Willie Wong's help, the question is solved. Using the titlesec package, and by adding the following line of code, every new paragraph is labeled as I desired:

\titleformat{\paragraph}[leftmargin]{\normalfont}{}{}{}

This is so long as the new paragraph is started with \paragraph{title/label here}, of course.

My previous example, with the implementation (see the attached image for result):

\documentclass[10pt]{article}
\usepackage{lipsum}
\usepackage{marginnote}
\usepackage{titlesec}
\usepackage{multicol}
\setlength{\columnsep}{10mm}

\begin{document}

\setlength\parindent{0em}
\setlength{\parskip}{1em}

\titleformat{\paragraph}[leftmargin]{\normalfont}{}{}{}

\begin{multicols*}{2}

\reversemarginpar

\paragraph{1.} \lipsum[1]

\paragraph{2.} \lipsum[1]

\paragraph{3.} \lipsum[1]

\end{multicols*}

\end{document}

Labeled paragraphs