14

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
    Commented 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
    Commented 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
    Commented Nov 19, 2018 at 15:10

3 Answers 3

14

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

9
2

If you can compile your document with lualatex, you could hightlight the text with the lua-ul package:

% !TeX TS-program = lualatex

\documentclass{beamer}

\usepackage{luacolor}
\usepackage{lua-ul}

\begin{document}

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

\end{document}

enter image description here

1

To highlight just a few words in beamer one can use \colorbox{yellow}{text}. This does not require extra packages or LuaLaTeX.

\documentclass{beamer}

\begin{document}

\begin{frame}
    \begin{block}{P1}
        Some \colorbox{yellow}{text} here
    \end{block} 
\end{frame}

\end{document}

enter image description here

You must log in to answer this question.

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