我遇到了类似的问题如何绘制带有圆角的框
我尝试制作圆形 boxex 用于海报展示,使用 mdframed-package 和 tikz-option 几乎可以成功。但内线几乎不圆,我看不出原因。一些小示例代码:
\documentclass{beamer}
\usepackage[orientation=portrait,size=a0,scale=1.4,debug]{beamerposter}
\usepackage[absolute,overlay]{textpos}
\usepackage[framemethod=tikz]{mdframed}
\tikzset{contour/.style = {rounded corners = 2ex}}
\definecolor{posterbackground}{RGB}{255,245,225} %beige
%\definecolor{blockborder}{RGB}{0,128,0} %green
%\definecolor{blockborder}{RGB}{0,0,0} %black
\definecolor{blockborder}{RGB}{235,235,235} %light grey
\mdfdefinestyle{frameborderstyle}%
{innerlinewidth=0.1em, innerlinecolor=black, middlelinewidth=1.0em, middlelinecolor=blockborder, outerlinewidth=0.1em, outerlinecolor=black, frametitlerule=false, innertopmargin=\topskip, backgroundcolor=posterbackground, roundcorner=0.5em}
%{outerlinecolor=blockborder, outerlinewidth=10pt, innerlinewidth=5pt, backgroundcolor=posterbackground, roundcorner=50pt}
\newenvironment{textframe}[4][]%
{\colorlet{currentcolor}{.} \fboxrule0.2em\fboxsep1.0em \begin{textblock*}{#2}(#3,#4) \begin{mdframed}[style=frameborderstyle, frametitle=#1]}
{\end{mdframed} \end{textblock*} \vspace{2.0ex}}
\begin{document}
\begin{frame}{blabla}
\begin{textframe}{1500pt}{50pt}{670pt}
this is written in a textpos-frame this is written in a textpos-frame this is written in a textpos-frame this is written in a textpos-frame this is written in a textpos-frame this is written in a textpos-frame this is written in a textpos-frame this is written in a textpos-frame this is written in a textpos-frame this is written in a textpos-frame this is written in a textpos-frame this is written in a textpos-frame this is written in a textpos-frame this is written in a textpos-frame
\end{textframe}
\end{frame}
\end{document}
我究竟做错了什么?
答案1
你必须了解 TikZ 对圆弧的计算。这很重要,因为mdframed
对内圆弧没有额外的修改。当然我可以实现它。
让我们采取以下 mwe:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[line width=2ex,rounded corners = 1ex] (0,0) rectangle (7,4);
\end{tikzpicture}
\end{document}
线宽为2ex
,弧长为1ex
。结果为:
如您所见,内弧不存在。如果您增加的rounded corners
幅度大于2ex
您将得到:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[line width=2ex,rounded corners = 3ex] (0,0) rectangle (7,4);
\end{tikzpicture}
\end{document}
与您的示例相关:您使用的是innerlinewidth=0.1em
,middlelinewidth=1.0em
并且outerlinewidth=0.1em
这导致宽度1.2em
。另一方面,您指定了roundcorner=0.5em
。正如解释的0.5em
那样太小了。
因此,您可以使用更大的尺寸,roundcorner
或者重新定义一些内部命令来指定内弧。