1

How can we underline a part of a text which is accompanied by a number beside the text as the below figure: enter image description here

  • 1
    For underlining see the soul package or the ulem package. For the number in the margin, I'd use marginnote for good placement (more precise than \marginpar) together with a custom counter. – Skillmon May 2 '18 at 17:45
3

My comment as code. Because of \refstepcounter you can even label those numbers.

\documentclass[]{article}

\usepackage{duckuments}
\usepackage{marginnote}
\usepackage{soul}
\usepackage{xcolor}
\definecolor{ulnumcolor}{HTML}{10d010}

\setul{}{.25ex}
\setulcolor{ulnumcolor}
\newcounter{ulnumcount}
\newcommand\ulnum[1]
  {\refstepcounter{ulnumcount}\marginnote{\theulnumcount}\ul{#1}}


\begin{document}
\blindduck
\ulnum{foobar}
\blindduck

\blindduck
\ulnum{bazbang}
\blindduck
\end{document}

enter image description here

  • File 'duckuments.sty' not found. \usepackege – Irreversible May 2 '18 at 18:03
  • is output!!!!!!!! – Irreversible May 2 '18 at 18:03
  • @Irreversible duckuments is not needed for the code to work, it is just to produce some dummy text. It is contained in the latest TeX Live and MikTeX distributions. You can leave it out and use the \ulnum macro in your file. – Skillmon May 2 '18 at 18:06
  • Thank you so much, is there any way to bold the number which is in the margine? – Irreversible May 2 '18 at 18:40
  • 1
    @Irreversible you might need to ask a new question about that new problem, then ;) – thymaro May 3 '18 at 9:28

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.