Putting a bar in the margin

The framed package provides a leftbar environment that does something like what you want:

enter image description here

\documentclass{article}
\usepackage{framed,lipsum}
\begin{document}
\lipsum[1]
\begin{leftbar}
This is a test.
\end{leftbar}
\lipsum[2]
\end{document}

Have a look at changebar package: https://ctan.org/pkg/changebar

An example:

\documentclass{article}
\usepackage[color]{changebar}
\cbcolor{blue}
\usepackage{lipsum}% for random text only
\begin{document}

\cbstart
\lipsum[1]
\cbend

\lipsum[2]
\end{document}

You can also use PDF annotations with the pdfcomment package

\documentclass{scrartcl}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{lipsum}
\usepackage[svgnames,rgb]{xcolor}
\usepackage[subject={Top1},author={Josef}]{pdfcomment}
\begin{document}
\begin{pdfsidelinecomment}[color=red,icolor=yellow,caption=inline,linebegin={/Butt},lineend={/Square},linewidth=2bp,linesep=1cm]{Example}
\lipsum[2]
\end{pdfsidelinecomment}
\end{document} 

enter image description here

Tags:

Rules

Margins