格式化页面标题中的矩形

格式化页面标题中的矩形

我想要安排一些东西,如下图原始矩形所示:

在此处输入图片描述 我想要这个:(角落的颜色不重要。) 在此处输入图片描述

\documentclass[a4paper]{article}
\usepackage[margin=1.5cm]{geometry}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes.misc}
\usetikzlibrary{calc,shapes.misc}

\newcommand\around{%
    \begin{tikzpicture}[overlay, remember picture]
        \draw[line width=2.1pt] {[rounded corners=0] ($(current page.north west)+(1cm,-4cm)$) --  ++(0,2cm) -- ($(current page.north east)+(-1cm,-2cm)$)} -- ++(0,-2cm) -- cycle;
        \draw[fill=yellow,line width=2.1pt] {[rounded corners=15] ($(current page.north west)+(1cm,-2cm)$) --  ++(0,1cm) -- ($(current page.north east)+(-15cm,-1cm)$)} -- ++(0,-1cm) -- cycle;
        \draw[fill=yellow,line width=2.1pt] {[rounded corners=15] ($(current page.north west)+(+15cm,-2cm)$) --  ++(0,1cm) -- ($(current page.north east)+(-1cm,-1cm)$)} -- ++(0,-1cm) -- cycle;
        \draw[fill=yellow,line width=2.1pt] {[rounded corners=0] ($(current page.north west)+(+6.3cm,-2cm)$) --  ++(0,1cm) -- ($(current page.north east)+(-6.3cm,-1cm)$)} -- ++(0,-1cm) -- cycle;
    \end{tikzpicture}
    \vspace{3cm}
}
\begin{document}
    \around
\end{document}

答案1

使用这样的节点可能有点棘手,这一点从许多类似问题的解决方案(如我在评论中链接的那个)中可以看出。默认使用 手动绘制实际矩形可能更容易rounded corners,如下所示:

\documentclass[a4paper]{article}
\usepackage[margin=1.5cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{calc}

\newcommand\around{%
    \begin{tikzpicture}[overlay, remember picture]
        \draw[line width=2.1pt] {[rounded corners=15] ($(current page.north west)+(1cm,-4cm)$) --  ++(0,3cm) -- ($(current page.north east)+(-1cm,-1cm)$)} -- ++(0,-3cm) -- cycle;
    \end{tikzpicture}
    \vspace{3cm}
}

\begin{document}
    \around
\end{document}

编辑:根据您的新问题,您可以执行以下操作:

\documentclass[a4paper]{article}
\usepackage[margin=1.5cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{calc}

\newcommand\around{%
    \begin{tikzpicture}[overlay, remember picture,line width=2.1pt]
        \draw ($(current page.north west)+(1cm,-4cm)$) rectangle ($(current page.north east)+(-1cm,-2cm)$);
    
        \draw[fill=yellow] {[rounded corners=15] ($(current page.north west)+(1cm,-2cm)$) -- ++(0,1cm)} -- ++(5cm,0) -- ++(0,-1cm) -- cycle;
        \draw[fill=yellow] {[rounded corners=15] ($(current page.north east)+(-1cm,-2cm)$) -- ++(0,1cm)} -- ++(-5cm,0) -- ++(0,-1cm) -- cycle;
        \draw[fill=yellow] ($(current page.north)+(-4cm,-2cm)$) -- ++(0,1cm) -- ($(current page.north)+(4cm,-1cm)$) -- ++(0,-1cm) -- cycle;
    \end{tikzpicture}
    \vspace{3cm}
}
\begin{document}
    \around
\end{document}

请注意,多次加载包并tikz自动加载是极其糟糕的做法graphicx

相关内容