2

I am using tcolorbox to highlight text. However, the color box starts from a new line even if I start highlight from the middle of a line.

\documentclass{article}
\usepackage[most]{tcolorbox}
\tcbset{enhanced jigsaw, boxrule=0pt,colback=yellow,arc=0pt,auto outer  arc,left=0pt,right=0pt,boxsep=0pt}

\begin{document}

This is a text that
\begin{tcolorbox}
I want to highlight. This further continues to multiple lines and paragraphs.
\end{tcolorbox}

\end{document}

I would like the highlight to start from the middle of line and then continue till the end of highlighted section of text which may span multiple lines and paragraphs, and may also end in the middle of a line.

I have also tried soul package with \hl command but it leaves a white space between the lines even if I change the height of highlight.

Thanks in advance for help.

2
  • You are welcome. For future reference, to produce a block of code, don't use the inline style of backticks at the beginning/end of code. Rather, highlight the block, and click the {} icon above the edit window. This will, to the editor, appear as if the code is indented 4 spaces. But to the reader, it will appear as a code block. Commented Oct 31, 2017 at 15:12
  • 1
    A tcolorbox always starts a new line while a tcbox cannot do it. But a tcbox can not do what you want. Try with solutions in tex.stackexchange.com/questions/5959/…
    – Ignasi
    Commented Oct 31, 2017 at 15:21

1 Answer 1

1

You can use the package soul and command \hl{•} to choose what sections of your text you want to highlight. (Just as you would do with bold fonts command \textbf{•}.) For instance, you can use it like this:

\documentclass{article}
\usepackage{color,soul}
\usepackage{lipsum}

\begin{document}
This is a text that:
I want to \hl{highlight}. This further continues to \hl{multiple lines and paragraphs}.
\lipsum[1]
\end{document}

It would look like this: highlighting-sample

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .