Semi-transparent text in beamer (pdflatex)
Asked Answered
K

7

8

I want to have some text appear semi-transparent, but not in an overlay fashion (where it eventually becomes solid) just permanently semi-transparent. To complicate matters, the text in question is part of a matrix:

$
\begin{matrix}
          & \{-2,3,5,0,8\} & \\
    \{-2,3,5,0\} & & \{-2,3,5,8\} \\
          & \{-2,3,5\} &
\end{matrix}
$

I want the third line in the matrix to be semi-transparent. Is there a way to do this?

Kidney answered 29/8, 2010 at 10:14 Comment(0)
K
14

Edit: improved the solution by turning it into a command with an optional argument.

Okay, discovered how to do it:

\newcommand{\semitransp}[2][35]{\textcolor{fg!#1}{#2}}

...

$
\begin{matrix}
       & \{-2,3,5,0,8\} & \\
    \{-2,3,5,0\} & & \{-2,3,5,8\} \\
      & \semitransp{\{-2,3,5\}} &
\end{matrix}
$

The optional parameter controls the transparency. So \semitransp[20]{text} is lighter, and \semitransp[60]{text} is heavier. The default value 35 looks good on my computer screen. It is yet to be seen how it looks projected on a wall.

Kidney answered 29/8, 2010 at 11:2 Comment(1)
@humleflue After your edit, that's now basically a duplicate of https://mcmap.net/q/1244049/-semi-transparent-text-in-beamer-pdflatexSilkweed
G
9

Ari's answer may work for him (and in 2010), but the given command will make all following text transparent, not only the given text.

An improved solution for making only the given text transparent:

\newcommand{\semitransp}[2][35]{\textcolor{fg!#1}{#2}}
% Swap \color with \textcolor and add another curly brackets pair.

...

$
\begin{matrix}
   & \{-2,3,5,0,8\} & \\
\{-2,3,5,0\} & & \{-2,3,5,8\} \\
  & \semitransp{\{-2,3,5\}} &
\end{matrix}
$
Geer answered 7/1, 2019 at 6:10 Comment(0)
S
5

To get real semi-transparency, one can use \pgfsetfillopacity. The advantage compared to faking the opacity by mixing the foreground colour with the background is, that this will also work if the there is a background image or some other coloured element.

\documentclass{beamer}

\begin{document}

\begin{frame}
$
\begin{matrix}
          & \{-2,3,5,0,8\} & \\
    \{-2,3,5,0\} & & \{-2,3,5,8\} \\
          & {\pgfsetfillopacity{0.2}\{-2,3,5\}} &
\end{matrix}
$

\end{frame} 


\setbeamertemplate{background canvas}{\includegraphics[width=\paperwidth]{example-grid-100x100bp}}


\begin{frame}
$
\begin{matrix}
          & \{-2,3,5,0,8\} & \\
    \{-2,3,5,0\} & & \{-2,3,5,8\} \\
          & {\pgfsetfillopacity{0.2}\{-2,3,5\}} &
\end{matrix}
$

\end{frame}     

\end{document}
Silkweed answered 27/2, 2019 at 10:19 Comment(0)
K
0

I came across the same problem but the approach suggested above did not work if an environment redefines the font or color. A more robust approach seems to use the package transparent from https://ctan.org/pkg/transparent

    \usepackage{transparent}
    \newcommand{\semitransp}[2][0.35]{{\transparent{#1}#2}}

A full working example is:

\documentclass{beamer}
\usepackage{transparent}
\newcommand{\semitransp}[2][0.35]{{\transparent{#1}#2}}


\begin{document}
    
\begin{frame}
  \semitransp{
    This is transparent. 
    \begin{itemize}
      \item This is also transparent.
    \end{itemize}
  }
\end{frame}

\end{document}

(this example works with the transparentpackage but not with the textcolor approach.)

Kimes answered 5/12, 2022 at 8:56 Comment(0)
R
0

In the spirit of the answer of N. Gast, I propose the following command to enable overlay specification:

\usepackage{transparent}
\newcommand<>{\semitransp}[2][0.35]{\alt#3{\transparent{#1}#2}{#2}}

Here is a MWE:

\documentclass{beamer}
\usepackage{transparent}
\newcommand<>{\semitransp}[2][0.35]{\alt#3{\transparent{#1}#2}{#2}}

\begin{document}
    
\begin{frame}
  \semitransp<2->{
    This is transparent on the second slide. 
    \begin{itemize}
      \item This is also transparent on the second slide.
    \end{itemize}
  }
\end{frame}

\end{document}
Racemose answered 13/3 at 14:53 Comment(0)
S
0

Not all overlays need to become solid:

\documentclass{beamer}

\setbeamercovered{transparent}

\begin{document}

\begin{frame}
$
\begin{matrix}
          & \{-2,3,5,0,8\} & \\
    \{-2,3,5,0\} & & \{-2,3,5,8\} \\
          & \uncover<0>{\{-2,3,5\}} &
\end{matrix}
$
\end{frame}

\end{document}

enter image description here

Silkweed answered 13/3 at 15:26 Comment(0)
S
0

You could use beamer's colormixin environment to fake a semitransparent colour:

\documentclass{beamer}

\begin{document}

\begin{frame}
$
\begin{matrix}
          & \{-2,3,5,0,8\} & \\
    \{-2,3,5,0\} & & \{-2,3,5,8\} \\
          & \begin{colormixin}{20!bg}
              \{-2,3,5\}
            \end{colormixin} &
\end{matrix}
$
\end{frame}

\end{document}

enter image description here

Silkweed answered 13/3 at 15:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.