Please, consider the snippet below.
I would like to cancel out the two middle terms of equation (1) and to cancel to 1 the expression in between the braces in equation (2).
If I use \cancel
and \cancelto
from the cancel
package, this results in a diagonal line starting too low and ending too high, as the expressions are very long. For small expressions, the results are good.
Some solutions to this problem were given in Diagonal strikeout starting too low and ending too high. However, these solutions seem to work just for inline equations. For example, the solution given by Speravir seems nice, but if I use it inside the align environment, it changes the typeset of the term being cancelled in such a way that it differs from the other terms, as exemplified below, with the second term that I want to cancel.
Questions:
Would it be possible to adapt the above-mentioned solution to work inside the align environment?
Would it be possible to create an equivalent \hcancelto command, to be used in equation (2)?
Thanks!
p.s. I use the yathesis
document class (to write theses in french) in the snippet to keep consistency with my document. Someone that doesn't have the yathesis
class installed can use the book or article classes instead.
\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}
Output: