PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Tikz: Dicker oberer Rahmen in abgerundeter Box



e271
12-09-2010, 19:19
Hallo,

ich habe mittels Tikz eine abgerundete Box um einen Text gebastelt. Wie kann ich denn den oberen Rand der Box dicker machen, wie z.B. im pfg-Manual (http://www.ctan.org/tex-archive/graphics/pgf/base/doc/generic/pgf/pgfmanual.pdf) auf Seite 233?



\documentclass[11pt, a4paper,fleqn]{scrartcl}
\usepackage{color}
\usepackage{framed}
\usepackage[table]{xcolor}
\usepackage{calc}
\usepackage{pgf,tikz}
\usetikzlibrary{shapes,decorations.pathmorphing,ba ckgrounds,arrows}
\pagestyle{empty}

\tikzstyle{mybox} = [draw=blue!60, fill=blue!20, very thick,
rectangle, rounded corners, inner sep=10pt]

\newenvironment{mysatz}[1][]{\begin{tikzpicture}%
\node [mybox] (rectangle) \bgroup%
\begin{minipage}{\textwidth-20pt}%
#1}{%
\end{minipage}%
\egroup;%
\end{tikzpicture}}

\begin{document}

\begin{mysatz}
Inhalt...
\end{mysatz}

\end{document}

Viele Grüße
Wolfgang

alexraasch
13-09-2010, 10:51
Im PGF-Manual wird das Rechteck mit der Background-Library gezeichnet und nicht mit \node. Versuch doch das mal und dann mit der "background top"-Eigenschaft arbeiten.

Spindoctor
13-09-2010, 14:43
vielleicht hilft dir auch clip...

e271
13-09-2010, 18:46
Im PGF-Manual wird das Rechteck mit der Background-Library gezeichnet und nicht mit \node. Versuch doch das mal und dann mit der "background top"-Eigenschaft arbeiten.
Das habe ich schon versucht (wie im Beispiel), aber dann ist der obere Rahmen eckig.

vielleicht hilft dir auch clip...Hättest Du dafür mal ein Minimalbeispiel?

Viele Grüße

Wolfgang

Spindoctor
14-09-2010, 10:18
Hallo!

Hier 2 Minimalbeispiele - allerdings hab ich nicht mit nodes gearbeitet (in tikz kenn ich mich noch nicht aus mit nodes). Schau mal, ob Du das für Deine Zwecke adaptieren kannst in irgendeiner Form...



documentclass{minimal}
\usepackage{tikz}

\begin{document}

Möglichkeit 1 (mit clip)

\begin{tikzpicture}
\draw[rounded corners=8pt,line width=4pt,color=black,fill=blue] (0,0) rectangle (\textwidth-20pt,5);%
\clip[rounded corners=8pt] (0,0) rectangle (\textwidth-20pt,5);% - alles was jetzt kommt muss wird von dem Rechteck mit abgerundeten Kanten beschnitten
\fill[color=black] (0,5) rectangle (\textwidth-20pt,4.5);%
\end{tikzpicture}

Möglichkeit 2 (nachdem du ohnehin ein gefülltes Rechteck willst)

\begin{tikzpicture}
\fill[rounded corners=8pt,line width=4pt,color=black] (0,0) rectangle (\textwidth-20pt,5);%
\fill[rounded corners=8pt,color=blue] (0+4pt,4.5cm) rectangle (\textwidth-24pt,0cm+4pt);%
\end{tikzpicture}

\end{document}

lösung 2 ist nicht ganz perfekt - da müsste man den Radius der runden Ecken noch anpassen... kannst du ja ggfs. mit calc machen

e271
14-09-2010, 17:16
#Spindoctor
Vielen Dank für das Beispiel. Es sieht auch gut aus, nur wo bringe ich denn jetzt z.B. folgendes unter:

\node [mybox] (box){%
\begin{minipage}{\textwidth-20pt}
To calculate the horizontal position the kinematic differential
equations are needed:
\begin{align}
\dot{n} &= u\cos\psi -v\sin\psi \\
\dot{e} &= u\sin\psi + v\cos\psi
\end{align}
For small angles the following approximation can be used:
\begin{align}
\dot{n} &= u -v\delta_\psi \\
\dot{e} &= u\delta_\psi + v
\end{align}
\end{minipage}
};

Viele Grüße

Wolfgang

Spindoctor
15-09-2010, 00:29
ich würde jetzt gerne sagen - ich hab dir den weg gezeichnet - durchführen musst ihn du.

Die Wahrheit ist aber, dass ich mich in pstricks nur wenig und in tikz noch überhaupt nicht mit nodes beschäftigt habe.

Ich glaube ich hab mit meinem Beispiel verdeutlichen können, wie man Rechtecke mit abgerundeten Ecken und dickem oberen Rand macht. Du musst jetzt noch herausfinden, wie man das mit nodes in Verbindung bringt. Dabei hilft dir hoffentlich das Manual oder andere User hier.

Bitte poste das Ergebnis - mich interessiert es auch.

Spindoctor
15-09-2010, 01:14
ok, hab mir mal kurz das manual angeschaut. Glaub es geht noch eleganter, aber das wär mal ein Ansatz

Try this:

\begin{tikzpicture}
\node [draw=blue!60, fill=blue!60, very thick,rectangle,rounded corners,inner sep=10pt,text width=\textwidth-20pt] {}
node [below=-5pt,draw=blue!60,fill=blue!20,very thick,rectangle,rounded corners,inner sep=10pt,text width=\textwidth-20pt]{%
To calculate the horizontal position the kinematic differential
equations are needed:
\ldots
};
\end{tikzpicture}

e271
15-09-2010, 07:43
@Spindoctor
Abgefahren!! Vielen Dank. Ich habe schon vieles ausprobiert aber da wäre ich im Leben nicht drauf gekommen.

Viele Grüße

Wolfgang