評論

評論

我試圖在數學表達式(尤其是在限制內)添加箭頭,以注意在解決限制時為某些項分配了一個值。我遇到過取消包及其命令\cancelto{}{} 但我有兩個問題: 1. 它刪除了該術語,就像它正在取消它一樣(顯然) 2. 它只向上(向右向上,但正確的部分不會打擾我),而當我顯示分數分母的趨勢時,我可能需要它向下。

在這裡搜尋時,我發現了一個可以完成這項工作的自訂命令(我對其進行了一些修改),並開始運行,遺憾的是它只工作了一半。另一半只是打亂方程中其他元素的所有基線。我將給您留下命令的程式碼(這不是我的功勞)和我遇到的錯誤,希望有人可以幫助我。我仍在學習 Tikz,所以我無法自己解決它,儘管我懷疑這就是我的問題的答案。

我修改的程式碼:

\usetikzlibrary{calc}

\newcommand*\canc[1]{%
  \mathchoice
    {\scriptstyle#1}
    {\scriptstyle#1}
    {\scriptscriptstyle#1}
    {\scriptscriptstyle#1}
}

\newcommand*\dtendto[2][0]{%
  \kern9pt%
  \begin{tikzpicture}[baseline=(current bounding box.center).anchor=east]
    \node[anchor=east] (a) {$#2$};
    \draw[->, color = red] ($(a.south)$) -- ($(a.south)-(-4pt,8pt)$) node
    at ($(a.south)-(-8pt,12pt)$) {$\canc{#1}$};
\end{tikzpicture}
}


\newcommand*\utendto[2][0]{%
  \kern9pt%
  \begin{tikzpicture}[baseline=(current bounding box.south).anchor=east]
    \node[anchor=east] (a) {$#2$};
    \draw[->, color = red] ($(a.north)$) -- ($(a.north)+(4pt,8pt)$) node
    at ($(a.north)+(8pt,12pt)$) {$\canc{#1}$};
\end{tikzpicture}
}

我遇到麻煩的部分(我之前的部分可以工作,但正確的程式碼肯定仍然可以工作)。

\lim_{x\to\infty} \frac{\bcancel{x^5}\cdot(\utendto[2]{2}
-\utendto[0]{\frac{3}{x^2}} +
\utendto[0]{\frac{2}{x^4}})}{\bcancel{x^5}\cdot\left(4 + \frac{5}{x}
-\frac{100}{x^5}\right)}

以及它如何顯示的快照,請注意,我希望發生的情況是將箭頭添加到頂部,就好像方程式甚至不知道它們在那裡一樣。現在看來它正在響應我添加的嘗試將 + 和 - 符號(如果我使用 \left( 和 \right) 的話甚至是括號)居中的內容,扭曲了正常的外觀。

錯誤影像

這是我希望它看起來像的 Photoshop 版本: 預期影像

基本上我想要的是忽略箭頭並排版的方程,就像它們不存在一樣(當然,垂直間距不與頂部或底部的其他線條或方程式疊加)。

我設法創建了一個名為\dtendto[]{} 的新命令,它的作用相同,只是箭頭向東南而不是東北,但我認為兩者的解決方案是相同的,以免使帖子更長我省略了它。

先謝,

答案1

評論

我添加了inner xsep=0ptouter sep=0pt,也限制了邊界框。

在我的編輯中,我刪除了該calc庫,因為它並不是真正需要的。此外,我設定了inner sep=0pt節點和shorten <=.3333em箭頭,以保留數字和箭頭之間的間距,同時取消數字下方的額外空間。

我用可縮放單位(exem)替換了所有值。

另外,您不需要宏,因為它在您的實作中\canc始終預設為。\scriptstyle

執行

\documentclass{article}
\pagestyle{empty}
\usepackage{tikz,cancel}
\renewcommand{\CancelColor}{\color{red}}

\newcommand*\dtendto[2][0]{%
    \begin{tikzpicture}[baseline=(a.base),every node/.style={inner sep=0pt,outer sep=0pt}]
        \node (a) {$#2$};
        \path[red] (a.south) node (b) at +(0.5em,-3ex) {$\scriptstyle #1$};
        \draw[->,red,shorten <=.3333em,shorten >=.3333em] (a) -- (b);
        \pgfresetboundingbox
        \path[use as bounding box] (a.north west) rectangle (a.south east |- b.south);
    \end{tikzpicture}
}


\newcommand*\utendto[2][0]{%
    \begin{tikzpicture}[baseline=(a.base),every node/.style={inner sep=0pt,outer sep=0pt}]
        \node (a) {$#2$};
        \path[red] (a.north) node (b) at +(0.5em,3ex) {$\scriptstyle #1$};
        \draw[->,red,shorten <=.3333em,shorten >=.3333em] (a) -- (b);
        \pgfresetboundingbox
        \path[use as bounding box] (a.south west) rectangle (a.north east |- b.north);
    \end{tikzpicture}
}
\begin{document}
\fbox{
$\displaystyle
    \lim_{x\to\infty} \frac{\bcancel{x^5}\cdot(\utendto[2]{2}
    -\utendto[0]{\frac{3}{x^2}} +
    \utendto[0]{\frac{2}{x^4}})}{\bcancel{x^5}\cdot\left(\dtendto[4]{4} + \frac{5}{x}
    -\frac{100}{x^5}\right)}
$
}
\end{document}

輸出

在實際輸出中,邊界框不會被反白。為了方便說明,我只是將它們塗成綠色。

在此輸入影像描述

相關內容