TransWikia.com

How to highlight text spanning multiple lines that includes macros?

TeX - LaTeX Asked by cero on March 6, 2021

I am currently proofreading a document and want to highlight some sentences. Unfortunately, I haven’t found a highlighting package that can both

  1. Preserve linebreaks
  2. Highlight text produced by macros, especially cite and the macros from siunitx such as SI

Using the changes package, linebreaks do not work (changes uses internally a colorbox). However, with soul, the macros do not work.
In the end, I would like to use highlight from changes, since it combines nicely with a comment function. By replacing the colorbox using

renewcommand{colorbox}[2]{colorlet{tmpcolor}{#1}sethlcolor{tmpcolor}hl{#2}}

I am able to "patch" the highlight command to use soul. For using cite with soul I can use soulregister as pointed out in How to make hl (highlighting) to automatically place incompatible commands in mbox?. However, this approach does not work for SI. The SI command, however, works, if it is surrounded by braces. But this is not an option for me, since I am not responsible for writing the original text. Including a preamble, however, is fine.

How can I do highlighting without having to change the text (aside from preambles and the surrounding command)? Ideally I would not need to include a separate entry for each macro, but it would be acceptable for me to do so. To some extent, crude hacks (such as redefining SI) would be ok as well.

MWE using changes

documentclass[11pt]{scrartcl}

usepackage[utf8]{inputenc}
usepackage{siunitx}
usepackage{changes}

begin{document}
After the introduction, highlight{this part of the sentence is quite long and contains a unit (SI{5}{ns}) and a citation~cite{myref}.} How do I highlight it?
end{document}

MWE using soul (with braces around SI)

documentclass[11pt]{scrartcl}

usepackage[utf8]{inputenc}
usepackage{siunitx}
usepackage{color}
usepackage{soul}

soulregistercite7
%soulregisterSI7 %Does not work

begin{document}
After the introduction, highlight{this part of the sentence is quite long and contains a unit ({SI{5}{ns}}) and a citation~cite{myref}.} How do I highlight it?
end{document}

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP