乳胶方程中的标记

乳胶方程中的标记

我想在乳胶中写出张量方程,表示等效指标,如下所示:

在此处输入图片描述

在此处输入图片描述

这里我使用了 MS Powerpoint 制作这些图片。虽然它可以工作,但使用这意味着我无法在 latex 和相关标签中使用公式编号。编辑这些图片变得很麻烦。

我需要的东西 -

  1. 指示索引数量的行
  2. \underbracket键入连接各个索引行的功能,并应允许重叠

有没有更优雅的解决方案,最好只使用乳胶?

答案1

欢迎来到 TeX.SE!!我认为这是一个可行的解决方案,但我不太确定你的第 2 点。我不知道这些行必须如何“指示索引的数量”。

但是我希望这会有所帮助。我做了两个pics。我将第一个称为vlines绘制那些必须“指示索引数”的垂直线。这pic需要一个参数:要绘制的线数。如果不存在,则绘制 2 条线。第二个picunderbracket绘制一条连接两个节点的线(在方程式中创建\tikzmarknode)。这pic需要四个参数:终点、初始点的 x 偏移、终点的 x 偏移和 y 偏移。

像这样:

\documentclass {article}
\usepackage    {lipsum}
\usepackage    {tikz}
\usetikzlibrary{calc}
\usetikzlibrary{tikzmark}

\tikzset
{
  pics/vlines/.default=2,
  pics/vlines/.style={% #1 -> number of lines (default 2)
    code={%
    \foreach\i in {1,...,#1}
      \draw[pic actions] (-0.05*#1+0.1*\i-0.05,-0.25) --++ (0,-0.25);
    }},
  pics/underbracket/.style n args={4}{% end point, initial delta x, final delta x, delta y
    code={%
      \draw (#2,-0.6) --++ (0,-#4) -| ($(#1)+(#3,-0.6)$);
    }},
}


\begin{document}
\lipsum[1] See equation \ref{eq:1}.

\begin{equation}\color{blue}
\tikzmarknode{F1}F_*^T \cdot 
\tikzmarknode{E1}E \cdot 
\tikzmarknode{F2}F_*=
\tikzmarknode{F3}F_*^T \stackrel{2}{*} 
\tikzmarknode{F4}F_*^T \cdot
\tikzmarknode{E2}E,\label{eq:1}
\end{equation}

\begin{tikzpicture}[remember picture,overlay]
\foreach\i in {F1,E1,F2,F3,F4,E2}
  \pic at (\i) {vlines};
\pic at (F1) {underbracket={E1}{ 0}    {-0.025}{0.5}};
\pic at (E1) {underbracket={F2}{ 0.025}{0}{0.5}};
\pic at (F3) {underbracket={E2}{ 0}    { 0.025}{0.75}};
\pic at (F4) {underbracket={E2}{ 0.025}{-0.025}{0.5}};
\end{tikzpicture}
\vspace*{1cm}% space for the overlay picture

\lipsum[2] See now equation \ref{eq:2}.

\begin{equation}
(\tikzmarknode{A}A   \stackrel{4}{*} 
 \tikzmarknode{C}C   \stackrel{2}{*} 
 \tikzmarknode{E}E)  \stackrel{3}{*}
 \tikzmarknode{B}B = \cdots\label{eq:2}
\end{equation}

\begin{tikzpicture}[remember picture,overlay]
\foreach\i in {A,E,B}
  \pic at (\i) {vlines};
\pic[red] at (C) {vlines={4}}; % four (red) lines (default 2)
\pic at (A) {underbracket={C}{0   }{-0.05}{0.25}};
\pic at (C) {underbracket={E}{0.05}{ 0   }{0.5}};
\pic at (C) {underbracket={B}{0   }{ 0   }{0.75}};
\end{tikzpicture}
\vspace*{1cm}% space for the overlay picture

\lipsum[3]
\end{document}

在此处输入图片描述

编辑:我改变了第二个pic灵感style安德鲁·史黛西的回答这个帖子。它的作用相同,但我认为语法更清晰一些。

新代码如下:

\documentclass {article}
\usepackage    {lipsum}
\usepackage    {tikz}
\usetikzlibrary{calc}
\usetikzlibrary{tikzmark}

\tikzset
{
  pics/vlines/.default=2,
  pics/vlines/.style={% #1 -> number of lines (default 2)
    code={%
    \foreach\i in {1,...,#1}
      \draw[pic actions] (-0.05*#1+0.1*\i-0.05,-0.25) --++ (0,-0.25);
    }},
  % idea taken from Andrew Stacey's answer: https://tex.stackexchange.com/questions/609102
  underb/.style n args={3}{% initial delta x, final delta x, delta y
    to path={++(#1,-0.6) --++ (0,-#3) -| ($(\tikztotarget)+(#2,-0.6)$)}
  }
}


\begin{document}
\lipsum[1] See equation \ref{eq:1}.

\begin{equation}\color{blue}
\tikzmarknode{F1}F_*^T \cdot 
\tikzmarknode{E1}E \cdot 
\tikzmarknode{F2}F_*=
\tikzmarknode{F3}F_*^T \stackrel{2}{*} 
\tikzmarknode{F4}F_*^T \cdot
\tikzmarknode{E2}E,\label{eq:1}
\end{equation}

\begin{tikzpicture}[remember picture,overlay]
\foreach\i in {F1,E1,F2,F3,F4,E2}
  \pic at (\i) {vlines};
\draw (F1) to[underb={0    }{-0.025}{0.5}]  (E1);
\draw (E1) to[underb={0.025}{ 0    }{0.5}]  (F2);
\draw (F3) to[underb={0    }{ 0.025}{0.75}] (E2);
\draw (F4) to[underb={0.025}{-0.025}{0.5}]  (E2);
\end{tikzpicture}
\vspace*{1cm}% space for the overlay picture

\lipsum[2] See now equation \ref{eq:2}.

\begin{equation}
(\tikzmarknode{A}A   \stackrel{4}{*} 
 \tikzmarknode{C}C   \stackrel{2}{*} 
 \tikzmarknode{E}E)  \stackrel{3}{*}
 \tikzmarknode{B}B = \cdots\label{eq:2}
\end{equation}

\begin{tikzpicture}[remember picture,overlay]
\foreach\i in {A,E,B}
  \pic at (\i) {vlines};
\pic[red] at (C) {vlines={4}}; % four (red) lines (default 2)
\draw (A) to[underb={0   }{-0.05}{0.25}] (C);
\draw (C) to[underb={0.05}{ 0   }{0.5}]  (E);
\draw (C) to[underb={0   }{ 0   }{0.75}] (B);
\end{tikzpicture}
\vspace*{1cm}% space for the overlay picture

\lipsum[3]
\end{document}

相关内容