Tikzmark 注释与页脚重叠

Tikzmark 注释与页脚重叠

目前,我的 tikzmark 注释与 fancyhdr 包定义的页脚重叠。

目前,我的方程式带有注释,定义如下

\begin{equation}
\tikzmarknode{A}{2}
\end{equation}
\begin{tikzpicture}[overlay,remember picture, shorten <= 1mm, font=\footnotesize]
\draw[red,<-] (A.south) -- ++ (-0.3,-1) node[below] {2 spin states};
\end{tikzpicture}

我假设我必须将方程式和 tikzmark 注释放在同一个框中,这样 LaTeX 就知道将整个框放在下一页上。正确的做法是什么?

编辑:我的方程看起来更像这样

\begin{equation}
    \tikzmarknode{A}{2}\left[\frac{\tikzmarknode{B}{(2k_{F})}}{\tikzmarknode{C}{\left(\frac{2\pi}{Na}\right)}}\right]=\tikzmarknode{D}{n}\tikzmarknode{E}{(Na)}
\end{equation}
\begin{tikzpicture}[overlay,remember picture,shorten <=1mm,font=\footnotesize]
    \draw[red,<-] (A.south) -- ++ (-0.3,-0.3) node[left,xshift=0.1cm,yshift=-0.1cm] {2 spin states};
    \draw[red,<-] (B.east) -- ++ (1,0.6) node[right] {volume of Fermi sea};
    \draw[red,<-] (C.south) -- ++ (0.2,-0.4) node[below right,xshift=-0.1cm,yshift=0.2cm] {volume corresponding to a single $k$ since $k$ is quantized as $k=\frac{2\pi m}{Na}$, $m\in\mathbb{Z}$};
    \draw[red,<-] (D.south) -- ++ (0.3,-0.3) node[right,xshift=-0.1cm,yshift=-0.1cm] {number density};
    \draw[red,<-] (E.east) -- ++(0.8,0.2) node[right] {length of chain};
\end{tikzpicture}

答案1

您可以测量注释的尺寸并在公式中添加相应的空间。但它的自动化程度仍然不如人们所希望的那样。

\documentclass[fleqn]{article}
\usepackage{amssymb}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{tikzmark,calc}
\begin{document}
\lipsum[1]
\begin{equation}
    \tikzmarknode{A}{2}\left[\frac{\tikzmarknode{B}{(2k_\mathrm{F})}}{\tikzmarknode{C}{\left(\frac{2\pi}{Na}\right)}}\right]=\tikzmarknode{D}{n}\tikzmarknode{E}{(Na)}
\begin{tikzpicture}[overlay,remember picture,shorten <=1mm,font=\footnotesize]
  \begin{scope}[local bounding box=annotations]
    \draw[red,<-] (A.south) -- ++ (-0.3,-0.3) node[left,xshift=0.1cm,yshift=-0.1cm] {2 spin states};
    \draw[red,<-] (B.east) -- ++ (1,0.6) node[right] {volume of Fermi sea};
    \draw[red,<-] (C.south) -- ++ (0.2,-0.4) node[below right,xshift=-0.1cm,yshift=0.2cm] {volume corresponding to a single $k$ since $k$ is quantized as $k=\frac{2\pi m}{Na}$, $m\in\mathbb{Z}$};
    \draw[red,<-] (D.south) -- ++ (0.3,-0.3) node[right,xshift=-0.1cm,yshift=-0.1cm] {number density};
    \draw[red,<-] (E.east) -- ++(0.8,0.2) node[right] {length of chain};
  \end{scope}
    \path let \p1=($(annotations.north)-(annotations.south)$),
  \p2=($(annotations.center)-(A.center)$),\n1={\y1-\baselineskip} in 
   \pgfextra{\xdef\myht{\n1}\xdef\mylift{\y2}};
\end{tikzpicture}
  \raisebox{\mylift}{$\begin{array}{@{}c@{}}\vspace{\myht}\end{array}$}
  \typeout{\myht}
\end{equation}
\lipsum[2]
\end{document}

在此处输入图片描述

答案2

tikzmark可能与页面上的任何内容重叠,其本身的含义和动机。为了避免重叠,您可以手动添加\vspace{8mm}(后面跟着一个空行),例如。

在此处输入图片描述

\documentclass{article}
\usepackage{tikz,lipsum}
\usetikzlibrary{tikzmark}
\begin{document}
\lipsum[1]
\begin{equation}
\tikzmarknode{A}{2}=1+1
\end{equation}
\begin{tikzpicture}[overlay,remember picture, shorten <= 1mm, font=\footnotesize]
\draw[red,<-] (A.south) -- ++ (-0.3,-1) node[below] {2 spin states};
\end{tikzpicture}
\vspace*{8mm}

\lipsum[1]
\end{document}

相关内容