请考虑下面的片段。
我想取消方程(1)的两个中间项,并将方程(2)中括号之间的表达式取消为 1。
如果我使用包中的\cancel
和,这会导致对角线起始太低结束太高,因为表达式非常长。对于小表达式,结果很好。\cancelto
cancel
针对此问题的一些解决方案斜线开始太低,结束太高。然而,这些解决方案似乎只适用于内联方程。例如,Speravir 给出的解决方案看起来不错,但是如果我在对齐环境中使用它,它会改变被取消的术语的排版,使其与其他术语不同,如下所示,我想要取消的第二个术语。
问题:
是否有可能调整上述解决方案以在对齐环境中工作?
是否有可能创建一个等效的 \hcancelto 命令,用于公式 (2)?
谢谢!
附言:为了与我的文档保持一致,我yathesis
在代码片段中使用了文档类(用法语写论文)。没有yathesis
安装该类的人可以使用书籍或文章类。
\documentclass[mainlanguage=english,babel={main=english,french,brazil},sepcorpaffilfrench={,~},sepcorpaffilenglish={,~},version=inprogress]{yathesis}
%\documentclass{book}
%\documentclass{article}
%
% If using XeLaTex or LuaLaTex
%\usepackage{fontspec}
%
% If using LaTex or PdfLaTex
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
%
\usepackage{lmodern} % latin modern font
\usepackage{amsmath}
\usepackage{cancel} % draw diagonal lines ("cancelling" a term)
%
%%% Code from https://tex.stackexchange.com/a/156581/95438 %%%
%
\usepackage{keycommand}
% Patch by Joseph Wright ("bug in the definition of \ifcommandkey (2010/04/27 v3.1415)"),
% https://tex.stackexchange.com/a/35794
\begingroup
\makeatletter
\catcode`\/=8 %
\@firstofone
{
\endgroup
\renewcommand{\ifcommandkey}[1]{%
\csname @\expandafter \expandafter \expandafter
\expandafter \expandafter \expandafter \expandafter
\kcmd@nbk \commandkey {#1}//{first}{second}//oftwo\endcsname
}
}
%--------%
\usepackage{tikz}
\usetikzlibrary{calc}
\newkeycommand{\hcancel}[hshiftstart=0pt,vshiftstart=0pt,hshiftend=0pt,vshiftend=0pt,color=red][1]{%
\tikz[baseline=(tocancel.base)]{
\node[inner sep=0pt,outer sep=0pt] (tocancel) {#1};
\draw[\commandkey{color}] ($(tocancel.south west)+(\commandkey{hshiftstart},\commandkey{vshiftstart})$) --
($(tocancel.north east)+(\commandkey{hshiftend},\commandkey{vshiftend})$);
}%
}%
%
%%% End of code %%%
%
\begin{document}
%
\begin{align}
\begin{split}
&= \mp \cos^{2} \left[ 2\pi\left( \frac{k}{2}t^{2} + f_{1}t + \varphi\right)\right] \int_{0}^{t} s_{i}\left( \tau\right) \sin \left[ 2\pi\left( kt + f_{1}\right)\tau\right] \, d\tau \\
&\mathrel{\phantom{=}} \cancel{\pm \frac{1}{2} \sin \left[ 4\pi\left( \frac{k}{2}t^{2} + f_{1}t + \varphi\right)\right] \int_{0}^{t} s_{i}\left( \tau\right) \cos \left[ 2\pi\left( kt + f_{1}\right)\tau\right] \, d\tau} \\
&\mathrel{\phantom{=}} \hcancel{$\mp \frac{1}{2} \sin \left[ 4\pi\left( \frac{k}{2}t^{2} + f_{1}t + \varphi\right)\right] \int_{0}^{t} s_{i}\left( \tau\right) \cos \left[ 2\pi\left( kt + f_{1}\right)\tau\right] \, d\tau$} \\
&\mathrel{\phantom{=}} \mp \sin^{2} \left[ 2\pi\left( \frac{k}{2}t^{2} + f_{1}t + \varphi\right)\right] \int_{0}^{t} s_{i}\left( \tau\right) \sin \left[ 2\pi\left( kt + f_{1}\right)\tau\right] \, d\tau
\end{split} \\
\begin{split}
&= \mp \left\lbrace \cancelto{1}{\cos^{2} \left[ 2\pi\left( \frac{k}{2}t^{2} + f_{1}t + \varphi\right)\right] + \sin^{2} \left[ 2\pi\left( \frac{k}{2}t^{2} + f_{1}t + \varphi\right)\right]} \right\rbrace \\
&\mathrel{\phantom{=}} \int_{0}^{t} s_{i}\left( \tau\right) \sin \left[ 2\pi\left( kt + f_{1}\right)\tau\right] \, d\tau
\end{split} \\
&= \mp \int_{0}^{t} s_{i}\left( \tau\right) \sin \left[ 2\pi\left( kt + f_{1}\right)\tau\right] \, d\tau
\end{align}
%
\end{document}
输出:
答案1
我有一个建议。最新版本的tikzmark
有一个新命令,\tikzmarkmode
,它有许多令人惊叹的功能,其中之一就是它可以检测您所处的模式。因此,$
如果您使用它,您不必添加任何内容,也不必担心内联方程式与显示样式。只需一张简单的路径图即可实现取消。
\documentclass[mainlanguage=english,babel={main=english,french,brazil},sepcorpaffilfrench={,~},sepcorpaffilenglish={,~},version=inprogress]{yathesis}
%\documentclass{book}
%\documentclass{article}
%
% If using XeLaTex or LuaLaTex
%\usepackage{fontspec}
%
% If using LaTex or PdfLaTex
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
%
\usepackage{lmodern} % latin modern font
\usepackage{amsmath}
\usepackage{cancel} % draw diagonal lines ("cancelling" a term)
%
%%% Code from https://tex.stackexchange.com/a/156581/95438 %%%
%
\usepackage{keycommand}
% Patch by Joseph Wright ("bug in the definition of \ifcommandkey (2010/04/27 v3.1415)"),
% https://tex.stackexchange.com/a/35794
\begingroup
\makeatletter
\catcode`\/=8 %
\@firstofone
{
\endgroup
\renewcommand{\ifcommandkey}[1]{%
\csname @\expandafter \expandafter \expandafter
\expandafter \expandafter \expandafter \expandafter
\kcmd@nbk \commandkey {#1}//{first}{second}//oftwo\endcsname
}
}
%--------%
\usepackage{tikz}
\usetikzlibrary{calc,tikzmark}
\newkeycommand{\hcancel}[hshiftstart=0pt,vshiftstart=0pt,hshiftend=0pt,vshiftend=0pt,color=red][1]{%
\tikz[baseline=(tocancel.base)]{
\node[inner sep=0pt,outer sep=0pt] (tocancel) {#1};
\draw[\commandkey{color}] ($(tocancel.south west)+(\commandkey{hshiftstart},\commandkey{vshiftstart})$) --
($(tocancel.north east)+(\commandkey{hshiftend},\commandkey{vshiftend})$);
}%
}%
\tikzset{cancel/.style={path picture={
\draw[#1] (path picture bounding box.south west) --
(path picture bounding box.north east);
}}}
%
%%% End of code %%%
%
\begin{document}
%
\begin{align}
\begin{split}
&= \mp \cos^{2} \left[ 2\pi\left( \frac{k}{2}t^{2} + f_{1}t + \varphi\right)\right] \int_{0}^{t} s_{i}\left( \tau\right) \sin \left[ 2\pi\left( kt + f_{1}\right)\tau\right] \, d\tau \\
&\mathrel{\phantom{=}} \cancel{\pm \frac{1}{2} \sin \left[ 4\pi\left( \frac{k}{2}t^{2} + f_{1}t + \varphi\right)\right] \int_{0}^{t} s_{i}\left( \tau\right) \cos \left[ 2\pi\left( kt + f_{1}\right)\tau\right] \, d\tau} \\
&\mathrel{\phantom{=}} \tikzmarknode[cancel]{cc}{\mp \frac{1}{2} \sin \left[ 4\pi\left( \frac{k}{2}t^{2} + f_{1}t + \varphi\right)\right] \int_{0}^{t} s_{i}\left( \tau\right) \cos \left[ 2\pi\left( kt + f_{1}\right)\tau\right] \, d\tau} \\
&\mathrel{\phantom{=}} \mp \sin^{2} \left[ 2\pi\left( \frac{k}{2}t^{2} + f_{1}t + \varphi\right)\right] \int_{0}^{t} s_{i}\left( \tau\right) \sin \left[ 2\pi\left( kt + f_{1}\right)\tau\right] \, d\tau
\end{split} \\
\begin{split}
&= \mp \left\lbrace \cancelto{1}{\cos^{2} \left[ 2\pi\left( \frac{k}{2}t^{2} + f_{1}t + \varphi\right)\right] + \sin^{2} \left[ 2\pi\left( \frac{k}{2}t^{2} + f_{1}t + \varphi\right)\right]} \right\rbrace \\
&\mathrel{\phantom{=}} \int_{0}^{t} s_{i}\left( \tau\right) \sin \left[ 2\pi\left( kt + f_{1}\right)\tau\right] \, d\tau
\end{split} \\
&= \tikzmarknode[cancel=red]{cc}{\mp \int_{0}^{t} s_{i}\left( \tau\right) \sin
\left[ 2\pi\left( kt + f_{1}\right)\tau\right] \, d\tau}
\end{align}
%
\end{document}
离题了,但我会把d
积分中出现的微分排版成直立的。