2

i want to resize and move Notepad from link: poster-layout: background and boxes and link Change width, height of Notepad

Minimal working example:

\documentclass{article}
\usepackage[most]{tcolorbox}
\usetikzlibrary{shadows,shapes.geometric}
\usepackage{lipsum}

\definecolor{mybrown}{RGB}{33,34,28}
\definecolor{myyellow}{RGB}{242,226,149}
\definecolor{mygreen}{RGB}{176,232,145}
\definecolor{myblue}{RGB}{61,139,189}
\definecolor{myorange}{RGB}{245,156,74}
\definecolor{mypurple}{RGB}{230,111,148}
\definecolor{myred}{RGB}{215,80,50}

\newtcolorbox{NotePad}[2][]{%
  enhanced,
  frame code=empty,
  boxsep=0.5cm,
  top=0.6cm,
  interior code={
  \fill[#2,drop shadow]
    (interior.south west) {[rounded corners=1.5cm]--
    (interior.south east)} --
    (interior.north east) --
    (interior.north west) --
    cycle;
  \fill[#2!80!black] 
    ([shift={(-0.9cm,0.5ex)}]interior.south east) to[out=30,in=-70]
    ([shift={(-0.55cm,0.7cm)}]interior.south east) to[out=-10,in=220]
    ([shift={(-0.7ex,0.9cm)}]interior.south east) to[out=250,in=30]
    cycle;  
  \fill[mybrown]
    ([yshift=-10pt]interior.north) circle [radius=0.23cm];
  \fill[mybrown!40]
    ([yshift=-10pt]interior.north) circle [radius=0.175cm];
  \node[
    cylinder,
    cylinder uses custom fill, 
    cylinder end fill=mybrown!60,
    cylinder body fill=mybrown,
    rotate=115,
    minimum width=9pt,
    minimum height=16pt
  ] 
  at ([shift={(-0.2pt,-9.8pt)}]interior.north) {};
  },
  #1
}



\begin{document}


%\column{.5\textwidth}
\tikz[overlay, remember picture] 
\node[anchor=south east,xshift=5.5cm, yshift=-3cm]
{
\begin{NotePad}[width=10cm,height =4cm]{myyellow}
Some test text for this block
\end{NotePad}
}
\tikz[overlay, remember picture] 
\node[anchor=south east,xshift=7.5cm, yshift=-10cm]
{
\begin{NotePad}[width=5cm,height=10cm]{myblue}
 test text 
\end{NotePad}
}

\end{document}

enter image description here

Please see attachment, this button of Notepad display wrong. Thanks

4
  • 3
    Your approach nests tikzpictures, which should be avoided, and leads to these effects. It is quite possible that, if you either use a \savebox for the cylinder or draw it with more basic methods, the problem will disappear, but as long as you nest tikzpictures you will never have full control.
    – user121799
    Commented Mar 27, 2019 at 14:29
  • 2
    To add to @marmot's comment: tcolorbox uses tikz so by using tcolorbox inside a tikz environment you're nesting tikz inside tikz.
    – JPi
    Commented Mar 27, 2019 at 14:34
  • @marmot JPi thank for comment. I see answer in link: tex.stackexchange.com/questions/398012/…. Can you correct above code? Thanks
    – latexforti
    Commented Mar 27, 2019 at 14:37
  • I do not necessarily agree with this answer. If you put a tcolorbox in a node it is always a gamble.
    – user121799
    Commented Mar 27, 2019 at 14:49

2 Answers 2

3

tcbposter is an environment offered by tcolorbox which allows easy ways for placing and dimensioning posterboxes. If you could use tcbposter you will avoid problems related with nesting tikzpictures.

Following code shows a little example. I've converted NotePad boxes to a tcbset style and used this style to configure posterboxes. As it's seen, posterbox dimensions can be automatically determined by poster grid or relative to other boxes.

\documentclass{article}
\usepackage[most]{tcolorbox}
\usetikzlibrary{shadows,shapes.geometric}
\usepackage{lipsum}

\definecolor{mybrown}{RGB}{33,34,28}
\definecolor{myyellow}{RGB}{242,226,149}
\definecolor{mygreen}{RGB}{176,232,145}
\definecolor{myblue}{RGB}{61,139,189}
\definecolor{myorange}{RGB}{245,156,74}
\definecolor{mypurple}{RGB}{230,111,148}
\definecolor{myred}{RGB}{215,80,50}

\tcbset{
NotePad/.style={%
  enhanced,
  frame code=empty,
  boxsep=0.5cm,
  top=0.6cm,
  interior code={
  \fill[#1,drop shadow]
    (interior.south west) {[rounded corners=1.5cm]--
    (interior.south east)} --
    (interior.north east) --
    (interior.north west) --
    cycle;
  \fill[#1!80!black] 
    ([shift={(-0.9cm,0.5ex)}]interior.south east) to[out=30,in=-70]
    ([shift={(-0.55cm,0.7cm)}]interior.south east) to[out=-10,in=220]
    ([shift={(-0.7ex,0.9cm)}]interior.south east) to[out=250,in=30]
    cycle;  
  \fill[mybrown]
    ([yshift=-10pt]interior.north) circle [radius=0.23cm];
  \fill[mybrown!40]
    ([yshift=-10pt]interior.north) circle [radius=0.175cm];
  \node[
    cylinder,
    cylinder uses custom fill, 
    cylinder end fill=mybrown!60,
    cylinder body fill=mybrown,
    rotate=115,
    minimum width=9pt,
    minimum height=16pt
  ] 
  at ([shift={(-0.2pt,-9.8pt)}]interior.north) {};
  },
}}



\begin{document}
\begin{tcbposter}[%
    poster={columns=3, rows=3},
    ]
    \posterbox[NotePad=myyellow]{name=A, column=1, span=2}{Some test text for this block}
    \posterbox[NotePad=myblue]{name=B, column=3, rowspan=3}{Some test text for this block}
    \posterbox[NotePad=myorange]{name=C, between=A and bottom, span=2}{Some test text for this block}
    \posterbox[NotePad=mypurple]{column=2, row=2, span=1.5, rowspan=1.5}{Some test text for this block}
    \posterbox[NotePad=mygreen]{at=C.west, xshift=1cm, yshift=-2cm}{Some test text for this block}

\end{tcbposter}

\end{document}

enter image description here

2

One should not nest tikzpictures, but this is what you are doing because tcolorbox is based on TikZ. As explained in this thread, what you always can do is to store the inner tikzpicture in a \savebox, and the use this \savebox in an node of the outer tikzpicture.

\documentclass{article}
\usepackage[most]{tcolorbox}
\usetikzlibrary{shadows,shapes.geometric}
\usepackage{lipsum}

\definecolor{mybrown}{RGB}{33,34,28}
\definecolor{myyellow}{RGB}{242,226,149}
\definecolor{mygreen}{RGB}{176,232,145}
\definecolor{myblue}{RGB}{61,139,189}
\definecolor{myorange}{RGB}{245,156,74}
\definecolor{mypurple}{RGB}{230,111,148}
\definecolor{myred}{RGB}{215,80,50}

\newtcolorbox{NotePad}[2][]{%
  enhanced,
  frame code=empty,
  boxsep=0.5cm,
  top=0.6cm,
  interior code={
  \fill[#2,drop shadow]
    (interior.south west) {[rounded corners=1.5cm]--
    (interior.south east)} --
    (interior.north east) --
    (interior.north west) --
    cycle;
  \fill[#2!80!black] 
    ([shift={(-0.9cm,0.5ex)}]interior.south east) to[out=30,in=-70]
    ([shift={(-0.55cm,0.7cm)}]interior.south east) to[out=-10,in=220]
    ([shift={(-0.7ex,0.9cm)}]interior.south east) to[out=250,in=30]
    cycle;  
  \fill[mybrown]
    ([yshift=-10pt]interior.north) circle [radius=0.23cm];
  \fill[mybrown!40]
    ([yshift=-10pt]interior.north) circle [radius=0.175cm];
  \node[
    cylinder,
    cylinder uses custom fill, 
    cylinder end fill=mybrown!60,
    cylinder body fill=mybrown,
    rotate=115,
    minimum width=9pt,
    minimum height=16pt
  ] 
  at ([shift={(-0.2pt,-9.8pt)}]interior.north) {};
  },
  #1
}


\newsavebox{\NPA}
\newsavebox{\NPB}

\begin{document}
\begin{lrbox}{\NPA}%
\begin{NotePad}[width=10cm,height =4cm]{myyellow}
Some test text for this block
\end{NotePad}%
\end{lrbox}%
\begin{lrbox}{\NPB}%
\begin{NotePad}[width=5cm,height=10cm]{myblue}
 test text 
\end{NotePad}%
\end{lrbox}%

%\column{.5\textwidth}
\tikz[overlay, remember picture]%
{\node[anchor=south east,xshift=5.5cm, yshift=-3cm]
{
\usebox\NPA
};}
\tikz[overlay, remember picture]%
{\node[anchor=south east,xshift=7.5cm, yshift=-10cm]
{
\usebox\NPB
};}

\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 .