以下程序输出下图。我的问题是:我可以改进这个程序以获得更精确的图像吗?节点不是计算出来的,而是通过反复试验得到的。有什么想法可以让程序代替我进行计算吗?
\documentclass{article}
\usepackage{tikz,amsmath}
\usepackage{systeme}
\usetikzlibrary{tikzmark}
\begin{document}
\hspace{2cm}\systeme{x+y=2 @\textcolor{red}{(1)},
\tikzmarknode{A}{}x-y\tikzmarknode{C}
{}=8\phantom{0}\tikzmarknode{B}{} @\textcolor{red}{(2)}}
\begin{tikzpicture}[overlay,remember picture]
%%%First Line
\node at ([yshift=-3ex]A.south) {$2x$};
\node at ([xshift=1.75ex,yshift=-3ex]C.south) {$=$};
\node at ([xshift=-1ex,yshift=-3ex]B.south) {$10$};
%%%Second Line
\node at ([xshift=-.75ex,yshift=-6.5ex]C.south) {$x$};
\node at ([xshift=1.75ex,yshift=-6.5ex]C.south) {$=$};
\node at ([xshift=-1.25ex,yshift=-6.5ex]B.south) {$5$};
%%%Draws line
\draw[-,black,semithick] ([yshift=-6pt]A.south) to
([yshift=-6pt]B.south);
\end{tikzpicture}
\end{document}
答案1
如果你真的想走这条路,那么你可能想要使用systeme
使用全部对齐,和 Ti钾Z 表示支撑和水平线。(最让我吃惊的是,它systeme
并没有被\tikzmarknode
s 搞糊涂。)
\documentclass{article}
\usepackage{tikz,amsmath}
\usepackage{systeme}
\usetikzlibrary{tikzmark,decorations.pathreplacing,calligraphy}
\begin{document}
\sysdelim..\hspace{2cm}\systeme{\tikzmarknode{x1}{x}+y=2 @\textcolor{red}{(1)},
\tikzmarknode{x2}{x}-y=8@\textcolor{red}{(2)},
\tikzmarknode{2x}{2x}=\tikzmarknode{10}{10},x=5}
\begin{tikzpicture}[overlay,remember picture]
\draw[decoration={calligraphic brace,raise=0.2em}, decorate, line
width=0.1em] ([yshift=-0.2em]x2.south west) -- ([yshift=0.3em]x1.north west);
\path (x2) -- (2x) coordinate[pos=0.65](aux);
\draw[very thick] (2x.west|-aux) -- (10.east|-aux);
\end{tikzpicture}
\end{document}