我在尝试绘制“大 X”以产生划掉单页内容的效果时遇到了一些问题。
X 的顶部基本上是我想要的位置(尽管该vspace*
命令在这里没有给出一致的结果),但是 X 的底部似乎总是跨越页面的宽度而不是文本的宽度。
这可能不是实现目标的最佳方式,但我可以这样做:
代码
\documentclass{book}
\textheight 8.25in \textwidth 5.75in
\usepackage{tikz}
\usepackage{lipsum}
\usepackage{xcolor}
\begin{document}
\begin{center}
\begin{LARGE}
\begin{minipage}{5.75in}\leftskip\fill\rightskip-\leftskip\parfillskip\stretch{2}%
\textbf{\textcolor{red}{A TITLE TO GO ALONG WITH THE TEXT THAT I WOULD LIKE TO BE PART OF WHAT THE 'X' CROSSES OUT}}
\end{minipage}
\end{LARGE}
\end{center}
\vskip 15pt
\large
\lipsum[1-4]\vspace*{-400pt}
\begin{tikzpicture}[remember picture,overlay]
\draw[line width=1.5pt, cap=round, black]
([yshift=-85pt]current page.south east) -- ([yshift=-310pt, xshift=85pt]current page.north west);
\draw[line width=1.5pt, cap=round, black]
([yshift=-85pt]current page.south west) -- ([yshift=-310pt, xshift=-85pt]current page.north east);
\end{tikzpicture}
\end{document}
产生输出
问题:我怎样才能画一个大 X,以便页面的内容整齐地划掉?除了我发布的代码之外,还有其他更易处理的替代方案吗?
谢谢。
答案1
使用该tikzpagenodes
包及其current page text area
。(注意:您需要运行两次)
\documentclass{book}
\textheight 8.25in \textwidth 5.75in
\usepackage{tikz}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{tikzpagenodes}%<--
\begin{document}
\begin{center}
\begin{LARGE}
\begin{minipage}{5.75in}\leftskip\fill\rightskip-\leftskip\parfillskip\stretch{2}%
\textbf{\textcolor{red}{A TITLE TO GO ALONG WITH THE TEXT THAT I WOULD LIKE TO BE PART OF WHAT THE 'X' CROSSES OUT}}
\end{minipage}
\end{LARGE}
\end{center}
\vskip 15pt
\large
\lipsum[1-4]
\begin{tikzpicture}[remember picture,overlay]
\draw[line width=1.5pt, cap=round, black]
(current page text area.north west) -- (current page text area.south east);%<--
\draw[line width=1.5pt, cap=round, black]
(current page text area.north east) -- (current page text area.south west);%<--
\end{tikzpicture}
\end{document}