2

I'm studying the nice code from Gonzalo Medina in from Mark (highlight) a paragraph (\item{...}) with a squiggly line for later attention . I love it! It will be very useful to me. However, I have noticed that two problems are appearing and I don’t know how to fix them.

A first problem: when the text between \Startsquiggly and \Endsquiggly generates two page breaks (so 3 pages in play) then the line in the margin does not cover page 2, just after the first page break, and resumes on page 3, after the second page break, along the remaining text to \Endsquiggly. Is there a command in your code that could allow the stroke to apply to page 2 as well? Example:

\begin{document}
\Startsquiggly \lipsum[1]\Endsquiggly

\Startsquiggly\lipsum[1-11]\Endsquiggly \end{document}

where the action of the command is not effective on page 2.

A second problem: if I only type:

\begin{document}
\Startsquiggly\lipsum[1-11]\Endsquiggly
\end{document}

then the editor gives me the following error message: ! Package pgf Error: No shape named `b 'is known.

Referring, I believe, to the tikzmark{b} in your code which seems to get lost ... However, this second problem does not occur in the first example. Can you think of a solution to these problems?

NB:

1 Answers1

3

This is an alternative solution made with tcolorbox. A new environment is defined for marked boxes. The lines survive to broken boxes and to as many pages as needed.

\documentclass{article}
\usepackage{lipsum}
\usepackage[most]{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}

\newtcolorbox{mybox}[1][]{% enhanced, blank, breakable, overlay={\draw[decoration={coil,aspect=0},decorate,ultra thick,gray] ([xshift=5mm]frame.north east)--([xshift=5mm]frame.south east);} }

\begin{document}

\lipsum[1]

\begin{mybox}\lipsum[1]\end{mybox}

\lipsum[1]

\begin{mybox}\lipsum[1-12]\end{mybox}

\end{document}

enter image description here

Ignasi
  • 136,588
  • It works very well. I don't know the blank option with tcolorbox! Now I know.I will post more questions about a transformation of this code in another post. Thank you. – StephaneC May 04 '21 at 12:06
  • Do you think that the Gonzalo Medina code can be adapted without these 2 problems? Using a command that can be placed in a line of text or between two \items is interesting. This avoids the new paragraph and boxes created by tcolorbox environments. – StephaneC May 04 '21 at 17:21