0

I'd like to create a box in tikz that contains regular text, and underneath that text, another layer of text. I can create the first layer of regular text, but I'm stumped on how to put the lower layer into the box.

The effect I'm going for is this: mock-up

where the large numeral 1 should be behind the text. Here's the MWE of the regular text in the box (the format of the box needs to be as specified here).

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,trees,calc}

\begin{document}

\begin{tikzpicture}[%
  every node/.style={%
    draw, %
    rectangle}, %
  text width=4cm, %
  minimum height=6\baselineskip]

\node{A bunch of text that is supposed to fill the box.};
\end{tikzpicture}

\end{document}
  • There is a semicolon missing and the width key does not exist (and wouldn't make sense since the text width is already 4cm). – user121799 Jun 26 '18 at 5:06
2

You could put the 1 on the background layer.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{backgrounds}

\begin{document}

\begin{tikzpicture}[%
  mynode/.style={%
    draw, %
    rectangle, %
  text width=4cm, %
  minimum height=6\baselineskip}]

\node[anchor=center,mynode] (txt){A bunch of text that is supposed to fill the box.};
\begin{scope}[on background layer]
\node[color=gray!40,scale=5,font=\sffamily] at (txt.center){1};
\end{scope}
\end{tikzpicture}

enter image description here

| improve this answer | |
2

If the box is not part of a tikzfigure, you could use tcolorbox and its watermark image or watermark text options.

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}

\begin{document}

\begin{tcolorbox}[
    enhanced,
    watermark text=Behind]
\lipsum[1]
\end{tcolorbox}

\tcbox[enhanced, watermark text=Some text]{This is the text in the front}

\begin{tcolorbox}[
    enhanced,
    sharp corners,
    colback=white,
    watermark color=red,
    watermark opacity=.5,
    watermark text=Behind]
\lipsum[1]
\end{tcolorbox}


\end{document}

enter image description here

| improve this answer | |

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.