我正在嘗試正確對齊tikzpicture
我放在頁腳中的箭頭內的由文字組成的內容。我的問題是我希望箭頭尖端與頁腳的東邊對齊和我希望文字的基線與頁腳其他部分中的其餘文字對齊。
似乎沒有一個錨定選項能產生我想要的結果。如果我使用base east
錨點,文字會正確對齊,但箭頭會伸出到邊距中,如下所示:
我知道如何添加手動班次。在下面的 MWE 中,我有一個或多或少可行的解決方案,透過使用yshift
將箭頭拉到正確的位置,但該值是我透過觀察它來確定的。該解決方案如下所示:
然而,它顯然只適用於此尺寸。有沒有辦法tikz
自動計算班次?
這是我的 MWE:
\documentclass{memoir}
\usepackage{tikz}
\usepackage{tikzpagenodes}
\usetikzlibrary{positioning,calc,shapes.arrows}
\usepackage{showframe}
\usepackage{lipsum}
\renewcommand*{\ShowFrameColor}{\color{red}}
% This version correctly aligns the CONTINUE text to the baseline,
% but the arrow head sticks out into the margin.
\newcommand{\ContinueNotice}{%
\begin{tikzpicture}[remember picture,overlay, font={\large\sffamily\bfseries}]
\node[single arrow,single arrow head extend=3pt,fill=black,text=white,anchor=base east]
at (current page footer area.south east) {\enspace CONTINUE\enspace};
\end{tikzpicture}%
}
% This version is more or less correctly aligned, but the yshift is done by eye.
\newcommand{\ContinueNoticeAlt}{%
\begin{tikzpicture}[remember picture,overlay, font={\large\sffamily\bfseries}]
\node[single arrow,single arrow head extend=3pt,fill=black,text=white,anchor=east,yshift=-2pt]
at (current page footer area.east) {\enspace CONTINUE\enspace};
\end{tikzpicture}%
}
\makepagestyle{TestStyle}
\makeoddfoot{TestStyle}{\footnotesize Some Notice}{\thepage}{\ContinueNotice}
\makeevenfoot{TestStyle}{\footnotesize Some Notice}{\thepage}{\ContinueNoticeAlt}
\pagestyle{TestStyle}
\begin{document}
\lipsum
\end{document}
答案1
使用anchor=east
或left
作為節點。用例如 命名節點n
並用作 的baseline=(n.base)
選項tikzpicture
:
\documentclass{memoir}
\usepackage{tikzpagenodes}
\usetikzlibrary{shapes.arrows}
\usepackage{showframe}
\usepackage{lipsum}
\renewcommand*{\ShowFrameColor}{\color{red}}
\newcommand{\ContinueNotice}{%
\begin{tikzpicture}[remember picture,overlay, font={\large\sffamily\bfseries},baseline=(n.base)]
\node[single arrow,single arrow head extend=3pt,fill=black,text=white,left](n)
at (current page footer area.south east) {\enspace CONTINUE\enspace};
\end{tikzpicture}%
}
\newcommand{\ContinueNoticeAlt}{%
\begin{tikzpicture}[remember picture,overlay, font={\large\sffamily\bfseries},baseline=(n.base)]
\node[single arrow,single arrow head extend=3pt,fill=black,text=white,anchor=east](n)
at (current page footer area.east) {\enspace CONTINUE\enspace};
\end{tikzpicture}%
}
\makepagestyle{TestStyle}
\makeoddfoot{TestStyle}{\footnotesize Some Notice}{\thepage}{\ContinueNotice}
\makeevenfoot{TestStyle}{\footnotesize Some Notice}{\thepage}{\ContinueNoticeAlt}
\pagestyle{TestStyle}
\begin{document}
\lipsum
\end{document}
更新
請注意,無需使用tikzpagenodes
和remember picture
。然後你只需運行一次。
\documentclass{memoir}
\usepackage{tikz}
\usetikzlibrary{shapes.arrows}
\usepackage{showframe}
\usepackage{lipsum}
\renewcommand*{\ShowFrameColor}{\color{red}}
\newcommand{\ContinueNotice}{%
\begin{tikzpicture}[overlay, font={\large\sffamily\bfseries},baseline=(n.base)]
\node[single arrow,single arrow head extend=3pt,fill=black,text=white,left](n)
{\enspace CONTINUE\enspace};
\end{tikzpicture}%
}
\newcommand{\ContinueNoticeAlt}{%
\begin{tikzpicture}[overlay, font={\large\sffamily\bfseries},baseline=(n.base)]
\node[single arrow,single arrow head extend=3pt,fill=black,text=white,anchor=east](n)
{\enspace CONTINUE\enspace};
\end{tikzpicture}%
}
\makepagestyle{TestStyle}
\makeoddfoot{TestStyle}{\footnotesize Some Notice}{\thepage}{\ContinueNotice}
\makeevenfoot{TestStyle}{\footnotesize Some Notice}{\thepage}{\ContinueNoticeAlt}
\pagestyle{TestStyle}
\begin{document}
\lipsum
\end{document}
結果與上面相同。