TikZ:xsetlength 和更小的线

TikZ:xsetlength 和更小的线

我正在尝试创建一个自定义环境warning,该环境的左上角有一个警告标志,周围有一个框架。但由于某种我不知道的原因,向西绘制的左侧线比cycle创建的线小得多。

线条更小

以下是 MWE:

\documentclass[leqno,hyperref={pdfpagemode=FullScreen},aspectratio=169]{beamer}
\usepackage[most]{tcolorbox}
\usetikzlibrary{calc}
\usepackage{lipsum}
\usepackage{fontawesome}

\newenvironment{warning}{%
\tcolorbox[enhanced,title=\faicon{warning},colback=white,
boxrule=0mm,coltitle=red,
attach boxed title to top left=
{yshift=-0.25mm-\tcboxedtitleheight/2,yshifttext=2mm-\tcboxedtitleheight/2},%
boxed title style={empty,arc=0pt,outer arc=0pt,boxrule=0pt, leftrule=-0.5em, toprule=-2pt}, 
frame code={
\draw[red,rounded corners=2pt,line width=0.8pt]  let \p1=($(title.north)-(frame.north)$) in
(title.north west) -- (title.north) -- ++ (\y1+0.2pt,-\y1+0.2pt) -|
([xshift=0.2pt, yshift=-0.4pt,rounded corners=0pt]frame.south east) -|
([xshift=-0.4pt, yshift=0.2pt,rounded corners=0pt]frame.west) -- cycle
;}]}
{\endtcolorbox}

\begin{document}
\begin{frame}
  \begin{warning}
    \lipsum[2]
  \end{warning}
\end{frame}
\end{document}

这肯定与绘图有关tikz,尤其是与x-shift命令有关,但我对此很陌生,看不到错误。这是一张完整的图片:

在此处输入图片描述

答案1

我只是将您的boxrule=0主 tcolorbox 更改为boxrule=0.8pt

作为一个独立的改变,我使用了newtcolorbox而不是newenvironment

我不确定 boxrule 为何会改变线宽,但我怀疑 boxrule 不是线,而是背景框和文本框之间的差异。这样boxrule=0pt,就没有足够的空间来放置线。

\documentclass[leqno,hyperref={pdfpagemode=FullScreen},aspectratio=169]{beamer}
\usepackage[most]{tcolorbox}
\usetikzlibrary{calc}
\usepackage{lipsum}
\usepackage{fontawesome}

\newtcolorbox{warning}{
enhanced,title=\faicon{warning},colback=white,
boxrule=0.8pt,coltitle=red,
attach boxed title to top left=
{yshift=-0.25mm-\tcboxedtitleheight/2,yshifttext=2mm-\tcboxedtitleheight/2},%
boxed title style={empty,arc=0pt,outer arc=0pt,boxrule=0pt, leftrule=-0.5em, toprule=-2pt}, 
frame code={
\draw[red,rounded corners=2pt,line width=0.8pt]  let \p1=($(title.north)-(frame.north)$) in
(title.north west) -- (title.north) -- ++ (\y1+0.2pt,-\y1+0.2pt) -|
([xshift=0.2pt, yshift=-0.4pt,rounded corners=0pt]frame.south east) -|
([xshift=-0.4pt, yshift=0.2pt,rounded corners=0pt]frame.west) -- cycle
;}}


\begin{document}
\begin{frame}
  \begin{warning}
    \lipsum[2]
  \end{warning}
\end{frame}
\end{document}

在此处输入图片描述

相关内容