鉴于
\documentclass{article}
\usepackage{tikz}
\usepackage[explicit]{titlesec}
\usepackage{geometry}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{shapes,shadows,calc}
\newcommand*{\MyNode}[1]{%
\begin{tikzpicture}[
node distance = 2mm,
S/.style = {signal, fill=orange,
signal to=east,
minimum height=3ex,
text depth=0.25ex,
inner sep=7,
font=\sffamily\bfseries}
]
\node (n1) [S] {\color{white} \huge\textbf{\fontfamily{ppl}\selectfont{#1}}};
\draw [line width=0.7mm, black] (n1.east) -- (\textwidth-3cm, 0);
\end{tikzpicture}
}
\titleformat{\section}
{\normalfont}{}{0em}
{\MyNode{#1}}
%
\begin{document}
\newgeometry{left=1cm,right=1cm, bottom=1cm}
\section{Education}
\section{Personal Projects}
\end{document}
产生输出
我想找到一种方法,让线条延伸到页面的右边距。
我尝试过的事情
我在网上查找了将右页边距绝对位置表示为变量的方法,Tikz
但没有成功。我进一步搜索了如何从内部存储给定形状的宽度值,Tikz
以便我可以做到\textwidth - \shapewidth
,但也没有成功。
有谁知道我怎样才能实现这个目标?
答案1
\documentclass{article}
\usepackage{tikz}
\usepackage[explicit]{titlesec}
\usepackage{geometry}
\usepackage{tikzpagenodes}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{shapes,shadows,calc}
\newcommand*{\MyNode}[1]{%
\begin{tikzpicture}[remember picture,
node distance = 2mm,
S/.style = {signal, fill=orange,
signal to=east,
minimum height=3ex,
text depth=0.25ex,
inner sep=7,
font=\sffamily\bfseries}
]
\node (n1) [S] {\color{white} \huge\textbf{\fontfamily{ppl}\selectfont{#1}}};
\draw [line width=0.7mm, black] (n1) -- (n1 -| current page text area.east);
\end{tikzpicture}}
\titleformat{\section}
{\normalfont}{}{0em}
{\MyNode{#1}}
%
\begin{document}
\newgeometry{left=1cm,right=1cm, bottom=1cm}
\section{Education}
\section{Personal Projects}
\end{document}