transparency in colorbox

I want to define my paragraphs and subsubsections to always be inside of a transparent box with a certain color.

I know that there's a transparency-package but this doesn't work with the PDF-view only with PS-view (i don't really understand why, but it seems that I can't use it for what i want to do), I also found a solution with the package tikz but i don't really understand how it works. Here is an Example where someone uses tikz and gets a transparent box with transparent text (I only want a transparent box - no transparent text).

Until now I only used Latex for writing protocols in a&a Style, so I don't know much about redefining commands and things like that. I am using the document class article with texmaker. I am producing a PDF-workbook for students so I need the solution to be compatible with PDF.

I'm trying to make a minimal example of what I did so far:

\documentclass[a4paper, 12pt, DIV10]{article}  \usepackage[ngerman]{babel} \usepackage{xcolor} \usepackage[explicit]{titlesec} \usepackage{lipsum}  \titleformat{\subsubsection}   {\normalfont\Large\bfseries}   {}   {0em}   {\colorbox{orange}{\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\textcolor{blue}{\thesection\quad#1}}}}     \setcounter{secnumdepth}{4}  \titleformat{\paragraph}   {\normalfont\Large\bfseries}   {}   {0em}   {\colorbox{red}{\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\textcolor{green}{\thesection\quad#1}}}}      \begin{document}    \section{Kapitel} \lipsum[1]   \subsubsection*{Erklärung} \lipsum[2]  \paragraph*{Übungen} \lipsum[3]    \end{document} 

I hope you can help me, if I forgot to mention anything let me know, and I'll figure it out.

Replay

Two variants:

\documentclass[a4paper, 12pt, DIV10]{article}

\usepackage[ngerman]{babel}
\usepackage{xcolor}
\usepackage[explicit]{titlesec}
\usepackage{lipsum}
\usepackage{tikz}
\titleformat{\subsubsection}
  {\normalfont\Large\bfseries}
  {}
  {0em}
  {\pgfsetfillopacity{0.5}\colorbox{orange}{\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\textcolor{blue}{\thesection\quad#1}}}\pgfsetfillopacity{1}}

\setcounter{secnumdepth}{4}

\titleformat{\paragraph}
  {\normalfont\Large\bfseries}
  {}
  {0em}
  {\tikz\node[opacity=0.5,fill=red,inner sep=\fboxsep,anchor=base]{\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\textcolor{green}{\thesection\quad#1}}};}

  \begin{document}

  \section{Kapitel}
\lipsum[1]

\subsubsection*{Erklärung}
\lipsum[2]

\paragraph*{Übungen}
\lipsum[3]

  \end{document}

transparency in colorbox

Side remark: In case the DIV10 in your example means that in your real document you aren't using article but a KOMA class, be aware that they don't like titlesec much.

Category: titlesec Time: 2016-07-28 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.122 (s). 12 q(s)