I have finally managed to do this with the double
and double distance
parameters of a tkiz style:
\definecolor{ltsiBlue1}{rgb}{0.0,0.4,1.0} % #0066ff
\tikzstyle{titlebox} = [draw=white, double=ltsiBlue1, double distance=2pt,
fill=ltsiBlue1, line width=3pt, text=white, rectangle,
inner sep=13pt, inner ysep=13pt]
\begin{tikzpicture}
\node [titlebox] (box){%
Hello world
};
\end{tkizpicture}
Here is the output, after some heavy butchering of one of the examples of beamerposter
Update
The version 1.2 of mdframed has new possibilities for setting the frame title. Based of your request you can simple use the option frametitlerule=true
and frametitlebackgroundcolor=gray!20
.
The current version is available at github.
\documentclass{article}
\usepackage[framemethod=TikZ]{mdframed}
\newenvironment{Frame}[1][]{%
\begin{mdframed}[%
frametitle={#1},
skipabove=\baselineskip plus 2pt minus 1pt,
skipbelow=\baselineskip plus 2pt minus 1pt,
linewidth=0.5pt,
frametitlerule=true,
frametitlebackgroundcolor=gray!30
]%
}{%
\end{mdframed}
}
\begin{document}
Text
\begin{Frame}[with Title]
Text
\end{Frame}
Text
\begin{Frame}% no Title
Text
\end{Frame}
Text
\end{document}
By using tikz
to modify the header here one suggestion.
You have to modify the command \mdframetitleenv
to influence the output. The package itself controls whether the frame title is empty or not.
\documentclass{article}
\usepackage[framemethod=TikZ]{mdframed}
\makeatletter
%ORIGINAL
%\providecommand*\mdframedtitleenv[1]{%
% \@afterindentfalse
% {\parindent \z@
% \setlength{\parfillskip}{\z@ plus 1fil}%
% \mdraggedtitle\nobreak\mdf@frametitlefont#1\relax%
% \par}%
% \@afterheading}
\tikzstyle{mybox} = [draw=black, %
fill=gray!20,%
line width=\mdf@middlelinewidth@length,
rectangle,
inner sep=0pt,
inner ysep=0.333em,
minimum height=1cm,
text width = \linewidth
+\mdf@innerleftmargin@length
+\mdf@innerrightmargin@length
+\mdf@linewidth@length,
align=left,
]
\renewcommand*{\mdframedtitleenv}[1]{%
\vspace*{\dimexpr-\mdf@innertopmargin@length-\mdf@linewidth@length\relax}%
\makebox[0pt][l]{%
\hspace*{\dimexpr-\mdf@innerleftmargin@length-\mdf@linewidth@length\relax}%
\begin{tikzpicture}[remember picture]
\node [mybox]{\hspace*{\mdf@innerrightmargin@length}%
\parbox{\linewidth}{\mdf@frametitlefont#1\relax}};%
\end{tikzpicture}%
}%
\par
\@afterheading
}%
\newenvironment{Frame}[1][]{%
\begin{mdframed}[%
frametitle={#1},
skipabove=\baselineskip plus 2pt minus 1pt,
skipbelow=\baselineskip plus 2pt minus 1pt,
linewidth=0.5pt,
]%
}{%
\end{mdframed}
}
\begin{document}
Text
\begin{Frame}[with Title]
Text
\end{Frame}
Text
\begin{Frame}[with Title with Title with Title with Title with Title with Title with Title with Title with Title with Title with Title with Title with Title with Title with Title with Title]
Text
\end{Frame}
Text
\begin{Frame}% no Title
Text
\end{Frame}
Text
\end{document}
Best Answer
As others have mentioned, the
mdframed
package allows you to obtain a colored frame in an easy way through thelinecolor=<color>
option. A complete example:A solution using the
framed
package is also easy to achieve. You can define a new environment to give a color to the frame; in the following example, I defined thecframed
environment to draw a colored frame around the text. The new environment simply defines\FrameCommand
to use a\fcolorbox
; the default frame color is blue and can be changed using an optional argument for the environment: