11

I am using beamer in Latex to make a presentation. I use a block for definition like:

 \begin{block}{P1}
 \justifying
  Some text here
 \end{block}

Let us say I wish to highlight a word "Some". By highlight, I mean something like which is performed by \hl{text}. However, hl does not work in a block in latex. So what should I do, if I want to highlight text in block in beamer.

I don't want to change the color of text but I want to highlight it as shown in attached image. alert changes the text color. hl does not work in a block. So how should I do it? enter image description here

3
  • 3
    Hello, did you consider using the \alert{text} command which colors your text using the colors defined by the beamer theme ?
    – Juklaa
    Nov 19, 2018 at 12:13
  • @JCoulet alert changes the text color, but I want too highlight it like a marker does. I have edited the question to show what exactly I want
    – ShJ
    Nov 19, 2018 at 14:47
  • Did that image come out of Cool Text Highlighting in LaTeX? That's a neat one! Still, if soul's \hl does not work in your case, most of those answers will also not work, for they rely on soul.
    – gusbrs
    Nov 19, 2018 at 15:10

1 Answer 1

11

You can apply the answer https://tex.stackexchange.com/a/41693/36296 to your problem:

\documentclass{beamer}

\usepackage{soul}
\makeatletter
\let\HL\hl
\renewcommand\hl{%
  \let\set@color\beamerorig@set@color
  \let\reset@color\beamerorig@reset@color
  \HL}
\makeatother
\begin{document}

\begin{frame}
 \begin{block}{P1}
  Some \hl{text} here
 \end{block}
\end{frame}

\end{document}

enter image description here

7
  • 1
    Is it possible to change the color of highlighter, which is yellow here to some other color?
    – ShJ
    Nov 19, 2018 at 15:21
  • 2
    @ShiS Have a look into the documentation of the soul package texdoc.net/texmf-dist/doc/latex/soul/soul.pdf Nov 19, 2018 at 15:23
  • If possible, can you direct me to a specific page where it is given in this document
    – ShJ
    Nov 19, 2018 at 15:25
  • 2
    @ShiS start with the "Short introduction and common rules" section Nov 19, 2018 at 15:27
  • 1
    @Raaja I think a quote from the answer I link to explains it pretty good: "beamer redefines nearly anything" :) Nov 19, 2018 at 20:44

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.