4

I've seen on this website several possibilities to include a line next to a paragraph. Like this: (the line is continuous)

text text text |
text text text |
text text text |

However, I would like to print that line on the margin, so that the original paragraph doesn't get any modification. In other examples the paragraph get an extra spacing with the next and previous paragraphs and the text is move a little to one side.

One of the other options I've seen is with the package pdfcomments, but I just want a real line, not a comment that will cause problems when printing. Is that possible? Maybe with Tikz?

8

The changebar package already does this:

\documentclass{article}
\usepackage[color]{changebar}
\usepackage{lipsum}

\setlength\changebarsep{10pt}

\begin{document}

\lipsum[4]
\cbstart
\lipsum[4]
\cbend
\lipsum[4]
\cbcolor{red}
\setlength\changebarwidth{6pt}
\cbstart
\lipsum[4]
\cbend

\end{document}

enter image description here

For a fancier version, you can see this answer to Mark (highlight) a paragraph (\item{...}) with a squiggly line for later attention.

| improve this answer | |
4

Thanks to Gonzalo Medina's response and with some modifications I've end up with:

\newcounter{tmp}
\newcommand\tikzmark[1]{%
  \tikz[overlay,remember picture] \node (#1) {};}

\def\separacionBarraInicial{.51}
\def\separacionBarraFinal{.53}

\newcommand\Startsquiggly{%
  \stepcounter{tmp}%
  \tikzmark{a}\label{a\thetmp}%
  \ifnum\getpagerefnumber{a\thetmp}=\getpagerefnumber{b\thetmp} \else
      \begin{tikzpicture}[overlay, remember picture]
        %\draw [decoration={coil,aspect=0},decorate,ultra thick,gray]
        \draw [decorate,ultra thick,black]
          let \p1 = (a.north), \p2 = (b), \p3 = (current page.center) in
          ( $ (\x3,\y1) + (\separacionBarraInicial\textwidth,1ex) $ ) --
          ( $ (\x3,\y1) + (\separacionBarraFinal\textwidth,1ex) $ ) --  
          ( $ (\x3,\y3) + (\separacionBarraFinal\textwidth,-0.51\textheight) $ );
      \end{tikzpicture}%
  \fi%
}

\newcommand\Endsquiggly{%
\tikzmark{b}\label{b\thetmp}
  \ifnum\getpagerefnumber{a\thetmp}=\getpagerefnumber{b\thetmp}
      \begin{tikzpicture}[overlay, remember picture]
        %\draw [decoration={coil,aspect=0},decorate,ultra thick,gray]
        \draw [decorate,ultra thick,black]
          let \p1 = (a.north), \p2 = (b), \p3 = (current page.center) in
          ( $ (\x3,\y1) + (\separacionBarraInicial\textwidth,1ex) $ ) -- 
          ( $ (\x3,\y1) + (\separacionBarraFinal\textwidth,1ex) $ ) --  
          ( $ (\x3,\y2) + (\separacionBarraFinal\textwidth,-0.75ex) $ ) --
          ( $ (\x3,\y2) + (\separacionBarraInicial\textwidth,-0.75ex) $ );
      \end{tikzpicture}%
  \else
      \begin{tikzpicture}[overlay, remember picture]
        %\draw [decoration={coil,aspect=0},decorate,ultra thick,gray]
        \draw [decorate,ultra thick,black]
          let \p1 = (a.north), \p2 = (b), \p3 = (current page.center) in
          ( $ (\x3,\y3) + (\separacionBarraFinal\textwidth,.495\textheight) $ ) -- 
          ( $ (\x3,\y2) + (\separacionBarraFinal\textwidth,-0.75ex) $ ) --
          ( $ (\x3,\y2) + (\separacionBarraInicial\textwidth,-0.75ex) $ );
      \end{tikzpicture}%
  \fi
}

\newcommand\Squ[1]{\Startsquiggly#1\Endsquiggly}

I've basically removed the "coil" decoration and make it a bit longer (both in its upper and lower part). And here's the final result

Final result

I would like to make a final remark, which is the problems caused by "changebar" to adjust its position (maybe because of a collision with other packages). So the solution with Tikz seems the best one.

| improve this answer | |
3

Next code produces similar results to Alvaro's selfanswer but with tcolorbox help.

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}

\newtcolorbox{markbox}{%
     enhanced, breakable, size=minimal, parbox=false, after={\par}, 
     before upper={\indent}, colback=white, 
     overlay = {\draw[line width=2pt] (frame.north east) -|
                       ([xshift=3mm]frame.east)|-(frame.south east);},
     overlay first={\draw[line width=2pt] (frame.north east) -|
                           ([xshift=3mm]frame.south east);},
     overlay middle={\draw[line width=2pt] ([xshift=3mm]frame.north east) -- 
                              ([xshift=3mm]frame.south east);},
     overlay last={\draw[line width=2pt] ([xshift=3mm]frame.north east)|-
                          (frame.south east);},
}

\begin{document}
\lipsum[1]
\begin{markbox}
\lipsum[2-11]
\end{markbox}
\lipsum[12]
\begin{markbox}
\lipsum[13]
\end{markbox}
\lipsum[14-15]
\end{document}

Hairy lines around marked paragraphs in next figures are viewer artifacts, they are not printed.

enter image description here enter image description here enter image description here

| improve this answer | |
  • You can get rid off the viewer artifacts, if you replace 'enhanced' by 'blank' or 'blanker'. – Thomas F. Sturm Jun 11 '14 at 15:48

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.