我想创建一个突出显示的方程式,如下所示。
但使用以下代码:
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,trees,positioning}
\author{Apurba Paul}
\begin{document}
\newcommand{\tikzmark}[1]{\tikz[baseline,remember picture] \node (#1) {};}
\tikzset{square arrow/.style={to path={-- ++(-10,-.25) -| (\tikztotarget)}}}
\begin{gather*}
y=\left[\frac{a}{\tikzmark{a}b}\frac{c}{\tikzmark{b}d}\right]\\
\tikz[remember picture]{\node(c){1'st part};}\qquad
\tikz[remember picture]{\node(d){2'nd picture};}
\tikz{\draw[->](a.south)to (c.north);}
\tikz{\draw[->](b.south)to (d.north);}
\end{gather*}
\end{document}
但我得到了这个
答案1
将选项remember picture
和添加overlay
到连接绘图命令:
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,trees,positioning}
\author{Apurba Paul}
\begin{document}
\newcommand{\tikzmark}[1]{\tikz[baseline,remember picture] \coordinate (#1) {};}
\tikzset{
square arrow/.style={
to path={-- ++(-10,-.25) -| (\tikztotarget)}
}
}
\begin{gather*}
y=\left[\frac{a}{\tikzmark{a}b}\frac{c}{\tikzmark{b}d}\right]\\[2ex]
\tikz[remember picture]{\node(c){1'st part};}\qquad
\tikz[remember picture]{\node(d){2'nd picture};}
\tikz[remember picture,overlay]{
\draw[->] (a.south)++(.25em,-.3ex) to (c.north) ;
\draw[->] (b.south)++(.25em,-.3ex) to (d.north) ;
}
\end{gather*}
\end{document}
答案2
没有 tikz:
\documentclass{article}
\usepackage{MnSymbol}
\usepackage{stackengine}
\renewcommand\useanchorwidth{T}
\usepackage{graphicx}
\stackMath
\begin{document}
\[
y = \bigg[
\def\stackalignment{r}
\stackunder{%
\stackunder{\displaystyle\frac{a}{b}}{\scalebox{2}{$\swarrow$}\,}%
}{\scriptstyle\mathsf{First~Part}~~}
\def\stackalignment{l}
\stackunder{%
\stackunder{\displaystyle\frac{c}{d}}{\,\,\scalebox{2}{$\searrow$}}%
}{\scriptstyle~~\mathsf{Second~Part}}
\bigg]
\]
\end{document}
如果您希望不使用这个MnSymbol
包来执行此操作,您可以使用它\rotatebox
来获取倾斜的箭头:
\documentclass{article}
\usepackage{stackengine}
\renewcommand\useanchorwidth{T}
\usepackage{graphicx}
\stackMath
\begin{document}
\[
y = \bigg[
\def\stackalignment{r}
\stackunder{%
\stackunder{\displaystyle\frac{a}{b}}{%
\scalebox{1.5}{\rotatebox{-30}{$\downarrow$}}\,}%
}{\scriptstyle\mathsf{First~Part}~~}
\def\stackalignment{l}
\stackunder{%
\stackunder{\displaystyle\frac{c}{d}}{%
\,\scalebox{1.5}{\rotatebox{30}{$\downarrow$}}}%
}{\scriptstyle~~\mathsf{Second~Part}}
\bigg]
\]
\end{document}
答案3
只是为了和 PSTricks 一起玩。
\documentclass[preview,border=12pt,12pt]{standalone}% change it back to your own document class
\usepackage{amsmath}
\usepackage{pst-node}
\begin{document}
$
\displaystyle
\!
\begin{gathered}
y = [\rnode[b]{L}{\frac{a}{b}}\rnode[b]{R}{\frac{c}{d}}]\\[12pt]
\rnode[t]{LT}{\text{First part}}\qquad \rnode[t]{RT}{\text{Second part}}
\psset{nodesep=3pt,arrows=->}
\ncline{L}{LT}\ncline{R}{RT}
\end{gathered}
$
\end{document}
答案4
您可以创建一个空白图片并使用上图将不同的组件封装到图片中的特定位置。
首先:创建一个任意大小的白色空白图片,将其命名为empty.jpg,然后将其放在与tex文件相同的文件夹中。
下面是 MWE。你只需要随意摆弄一下坐标。但要注意:有两个坐标系。一个来自上图,以及来自 tikz 的。
\documentclass{article}
\usepackage{subfigure}
\usepackage{overpic}
\usepackage{tikz}
\begin{document}
\begin{figure}
\centering
\subfigure{
\begin{overpic}[width=5cm,height=5cm]{empty.jpg}\label{eq:equation1}
\put(45,50){ $y=\left[\frac{a}{b}\frac{c}{d}\right]$ }
\put(45,30){
\begin{tikzpicture}[scale=0.1]
\draw[->,thin] (0,0) -- (-5,-5);
\draw[->,thin] (2,0) -- (7,-5);
\end{tikzpicture} }
\put(20,20){1'st part}
\put(60,20){2'nd picture}
\end{overpic} }
\end{figure}
\end{document}