开发者

How to only round selected corners in a fancytitle box with Tikz

If you take a look at http://www.texample.net/tikz/examples/boxes-with-text-and-math/ the boxes there are with rounded corners. In the examples, both the box itself and the title is a box. I want the title box to not have the bottom corners rounded.

On page 120 in the manual, there is a description of how to draw with and without rounded corners. However, I want to use this in a fancytitle. It looks a bit silly to have the fancytitle as a box where all corners are rounded when it is as wide as the box itself.

  \begin{tikzpicture}[baseline=-2cm]
    \node [mybox] (box){
      \begin{minipage}[t!]{0.50\textwidth}
        Help, I'm a box
      \end{minipage}
    };
    \node[fancytitle, text width=0.5423\textwidth, text centered, rounded corners] at (box.north) {Help, I'm a title};
  \end{tikzpicture}

The style I use is this

  \tikzstyle{mybox} = [draw=red, fill=blue!20, very thick,
    rectangle, rounded corners, inner sep=1开发者_JAVA百科0pt, inner ysep=20pt]
  \tikzstyle{fancytitle} = [fill=red, text=white]


Possibly the most simple way to achieve the effect (with out solving the problem) is as follows.

Add name=title to the title node.

then draw a line along the bottom of the title node.

\draw [draw=red,line width=2pt] (title.south west) -- (title.south east);

This gives two little spots where the line over shoots, to fix this you can add.

\usetikzlibrary{calc}

And move make the line 1 point shorter at each end, and up a bit.
\draw [draw=red,line width=2pt] ($(title.south west)+(+1pt,+1pt)$) -- ($(title.south east)+(-1pt,+1pt)$) ;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜