1

How can I draw the red line under the gray TEXT box? The white background should be transparent.

\documentclass{scrbook}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{shapes}

\tikzstyle{style}=[rectangle split, rectangle split parts=2, rectangle split part fill={white, gray}, rectangle split horizontal=false, draw=black, thick]

\begin{document}
\begin{tikzpicture}
  \node[style, minimum size=5cm](A) {
      \begin{tikzpicture}
        \node[style, minimum size=2cm](B) {
          123456789123456789
          \nodepart{two}TEXT};
      \end{tikzpicture}
      \nodepart{two}TEXT
  };
  \draw[-, red, thick](A.north west) -- (A.south east);
\end{tikzpicture}
\end{document}
1
  • Try adding opacity=<between 0 and 1>, say 0.3, into the draw options at the last line.
    – Jesse
    Nov 2, 2013 at 5:15

1 Answer 1

2

Is it like this?

\documentclass{scrbook}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{shapes,calc}

\tikzstyle{style}=[rectangle split, rectangle split parts=2, rectangle split part fill={white, gray}, rectangle split horizontal=false, draw=black, thick]

\begin{document}
\begin{tikzpicture}
  \node[style, minimum size=5cm](A) {
      \begin{tikzpicture}
        \node[style, minimum size=2cm](B) {
          123456789123456789
          \nodepart{two}TEXT};
      \end{tikzpicture}
      \nodepart{two}TEXT
  };
  \draw[-, red, thick]($(A.south west) + (0,-.5ex)$) -- ($(A.south east) + (0,-.5ex)$);
\end{tikzpicture}
\end{document}

enter image description here

Or this:

\documentclass{scrbook}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{shapes,calc}

\tikzset{
style/.style={rectangle split, rectangle split parts=2, rectangle split part fill={white, gray}, rectangle split horizontal=false, draw=black, thick}
}

\begin{document}
\begin{tikzpicture}
  \node[style, minimum size=5cm](A) {
      \begin{tikzpicture}
        \node[style, minimum size=2cm](B) {
          123456789123456789
          \nodepart{two}TEXT};
          \draw[-, red, thick]($(B.south west) + (0,-.5ex)$) -- ($(B.south east) + (0,-.5ex)$);
      \end{tikzpicture}
      \nodepart{two}TEXT
  };
  \draw[-, red, thick]($(A.south west) + (0,-.5ex)$) -- ($(A.south east) + (0,-.5ex)$);
\end{tikzpicture}
\end{document}

enter image description here

Using tikzpicture inside tikzpicture can be troublesome. Also instead of tikzstyle, use tikzset (as in the latter code) as the former is deprecated.

Or this:

\documentclass{scrbook}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds}

\tikzset{
style/.style={rectangle split, rectangle split parts=2, rectangle split part fill={none, gray}, rectangle split horizontal=false, draw=black, thick}
}

\begin{document}
\begin{tikzpicture}
  \node[style, minimum size=5cm,opacity=1](A) {
      \begin{tikzpicture}
        \node[style, minimum size=2cm](B) {
          123456789123456789
          \nodepart{two}TEXT};
      \end{tikzpicture}
      \nodepart{two}TEXT
  };
  \begin{pgfonlayer}{background}
  \draw[-, red, thick,](A.north west) -- (A.south east);
  \end{pgfonlayer}
\end{tikzpicture}
\end{document}

enter image description here

3
  • Ah, now I am confused. :-)
    – user11232
    Nov 2, 2013 at 8:14
  • Thx. It is not really what I want but your examples put me on the right track... :) "rectangle split part fill={none, gray}" together with "pgfonlayer" solved my problem.
    – user4811
    Nov 2, 2013 at 13:34
  • @user4811 Glad it helped. You meant behind not under :-). I have updated the answer for the record.
    – user11232
    Nov 2, 2013 at 13:41

You must log in to answer this question.

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