Need help to create a more flexible cancel command that works inside an align environment
up vote
2
down vote
favorite
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}//oftwoendcsname
}
}
%--------%
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[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau \
&mathrel{phantom{=}} cancel{pm frac{1}{2} sin left[ 4pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) cos left[ 2pileft( kt + f_{1}right)tauright] , dtau} \
&mathrel{phantom{=}} hcancel{$mp frac{1}{2} sin left[ 4pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) cos left[ 2pileft( kt + f_{1}right)tauright] , dtau$} \
&mathrel{phantom{=}} mp sin^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau
end{split} \
begin{split}
&= mp leftlbrace cancelto{1}{cos^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] + sin^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right]} rightrbrace \
&mathrel{phantom{=}} int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau
end{split} \
&= mp int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau
end{align}
%
end{document}
Output:
tikz-pgf align cancel
add a comment |
up vote
2
down vote
favorite
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}//oftwoendcsname
}
}
%--------%
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[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau \
&mathrel{phantom{=}} cancel{pm frac{1}{2} sin left[ 4pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) cos left[ 2pileft( kt + f_{1}right)tauright] , dtau} \
&mathrel{phantom{=}} hcancel{$mp frac{1}{2} sin left[ 4pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) cos left[ 2pileft( kt + f_{1}right)tauright] , dtau$} \
&mathrel{phantom{=}} mp sin^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau
end{split} \
begin{split}
&= mp leftlbrace cancelto{1}{cos^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] + sin^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right]} rightrbrace \
&mathrel{phantom{=}} int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau
end{split} \
&= mp int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau
end{align}
%
end{document}
Output:
tikz-pgf align cancel
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
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}//oftwoendcsname
}
}
%--------%
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[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau \
&mathrel{phantom{=}} cancel{pm frac{1}{2} sin left[ 4pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) cos left[ 2pileft( kt + f_{1}right)tauright] , dtau} \
&mathrel{phantom{=}} hcancel{$mp frac{1}{2} sin left[ 4pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) cos left[ 2pileft( kt + f_{1}right)tauright] , dtau$} \
&mathrel{phantom{=}} mp sin^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau
end{split} \
begin{split}
&= mp leftlbrace cancelto{1}{cos^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] + sin^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right]} rightrbrace \
&mathrel{phantom{=}} int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau
end{split} \
&= mp int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau
end{align}
%
end{document}
Output:
tikz-pgf align cancel
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}//oftwoendcsname
}
}
%--------%
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[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau \
&mathrel{phantom{=}} cancel{pm frac{1}{2} sin left[ 4pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) cos left[ 2pileft( kt + f_{1}right)tauright] , dtau} \
&mathrel{phantom{=}} hcancel{$mp frac{1}{2} sin left[ 4pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) cos left[ 2pileft( kt + f_{1}right)tauright] , dtau$} \
&mathrel{phantom{=}} mp sin^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau
end{split} \
begin{split}
&= mp leftlbrace cancelto{1}{cos^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] + sin^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right]} rightrbrace \
&mathrel{phantom{=}} int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau
end{split} \
&= mp int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau
end{align}
%
end{document}
Output:
tikz-pgf align cancel
tikz-pgf align cancel
edited 2 days ago
Dũng Vũ
1,05018
1,05018
asked 2 days ago
Joao Alberto
995
995
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
I have a proposal. The latest version of tikzmark
has a new command, tikzmarkmode
, which has many stunning features, one of which being that it detects the mode you're in. Hence, you do not have to add any $
nor worry about inline equation vs. display style if you use it. The cancellation can be achieved with a simple path picture.
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}//oftwoendcsname
}
}
%--------%
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[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau \
&mathrel{phantom{=}} cancel{pm frac{1}{2} sin left[ 4pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) cos left[ 2pileft( kt + f_{1}right)tauright] , dtau} \
&mathrel{phantom{=}} tikzmarknode[cancel]{cc}{mp frac{1}{2} sin left[ 4pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) cos left[ 2pileft( kt + f_{1}right)tauright] , dtau} \
&mathrel{phantom{=}} mp sin^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau
end{split} \
begin{split}
&= mp leftlbrace cancelto{1}{cos^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] + sin^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right]} rightrbrace \
&mathrel{phantom{=}} int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau
end{split} \
&= tikzmarknode[cancel=red]{cc}{mp int_{0}^{t} s_{i}left( tauright) sin
left[ 2pileft( kt + f_{1}right)tauright] , dtau}
end{align}
%
end{document}
Off-topic but I would typeset the differential d
s that appear in the integrals upright.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
I have a proposal. The latest version of tikzmark
has a new command, tikzmarkmode
, which has many stunning features, one of which being that it detects the mode you're in. Hence, you do not have to add any $
nor worry about inline equation vs. display style if you use it. The cancellation can be achieved with a simple path picture.
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}//oftwoendcsname
}
}
%--------%
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[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau \
&mathrel{phantom{=}} cancel{pm frac{1}{2} sin left[ 4pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) cos left[ 2pileft( kt + f_{1}right)tauright] , dtau} \
&mathrel{phantom{=}} tikzmarknode[cancel]{cc}{mp frac{1}{2} sin left[ 4pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) cos left[ 2pileft( kt + f_{1}right)tauright] , dtau} \
&mathrel{phantom{=}} mp sin^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau
end{split} \
begin{split}
&= mp leftlbrace cancelto{1}{cos^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] + sin^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right]} rightrbrace \
&mathrel{phantom{=}} int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau
end{split} \
&= tikzmarknode[cancel=red]{cc}{mp int_{0}^{t} s_{i}left( tauright) sin
left[ 2pileft( kt + f_{1}right)tauright] , dtau}
end{align}
%
end{document}
Off-topic but I would typeset the differential d
s that appear in the integrals upright.
add a comment |
up vote
0
down vote
I have a proposal. The latest version of tikzmark
has a new command, tikzmarkmode
, which has many stunning features, one of which being that it detects the mode you're in. Hence, you do not have to add any $
nor worry about inline equation vs. display style if you use it. The cancellation can be achieved with a simple path picture.
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}//oftwoendcsname
}
}
%--------%
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[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau \
&mathrel{phantom{=}} cancel{pm frac{1}{2} sin left[ 4pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) cos left[ 2pileft( kt + f_{1}right)tauright] , dtau} \
&mathrel{phantom{=}} tikzmarknode[cancel]{cc}{mp frac{1}{2} sin left[ 4pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) cos left[ 2pileft( kt + f_{1}right)tauright] , dtau} \
&mathrel{phantom{=}} mp sin^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau
end{split} \
begin{split}
&= mp leftlbrace cancelto{1}{cos^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] + sin^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right]} rightrbrace \
&mathrel{phantom{=}} int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau
end{split} \
&= tikzmarknode[cancel=red]{cc}{mp int_{0}^{t} s_{i}left( tauright) sin
left[ 2pileft( kt + f_{1}right)tauright] , dtau}
end{align}
%
end{document}
Off-topic but I would typeset the differential d
s that appear in the integrals upright.
add a comment |
up vote
0
down vote
up vote
0
down vote
I have a proposal. The latest version of tikzmark
has a new command, tikzmarkmode
, which has many stunning features, one of which being that it detects the mode you're in. Hence, you do not have to add any $
nor worry about inline equation vs. display style if you use it. The cancellation can be achieved with a simple path picture.
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}//oftwoendcsname
}
}
%--------%
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[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau \
&mathrel{phantom{=}} cancel{pm frac{1}{2} sin left[ 4pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) cos left[ 2pileft( kt + f_{1}right)tauright] , dtau} \
&mathrel{phantom{=}} tikzmarknode[cancel]{cc}{mp frac{1}{2} sin left[ 4pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) cos left[ 2pileft( kt + f_{1}right)tauright] , dtau} \
&mathrel{phantom{=}} mp sin^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau
end{split} \
begin{split}
&= mp leftlbrace cancelto{1}{cos^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] + sin^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right]} rightrbrace \
&mathrel{phantom{=}} int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau
end{split} \
&= tikzmarknode[cancel=red]{cc}{mp int_{0}^{t} s_{i}left( tauright) sin
left[ 2pileft( kt + f_{1}right)tauright] , dtau}
end{align}
%
end{document}
Off-topic but I would typeset the differential d
s that appear in the integrals upright.
I have a proposal. The latest version of tikzmark
has a new command, tikzmarkmode
, which has many stunning features, one of which being that it detects the mode you're in. Hence, you do not have to add any $
nor worry about inline equation vs. display style if you use it. The cancellation can be achieved with a simple path picture.
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}//oftwoendcsname
}
}
%--------%
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[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau \
&mathrel{phantom{=}} cancel{pm frac{1}{2} sin left[ 4pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) cos left[ 2pileft( kt + f_{1}right)tauright] , dtau} \
&mathrel{phantom{=}} tikzmarknode[cancel]{cc}{mp frac{1}{2} sin left[ 4pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) cos left[ 2pileft( kt + f_{1}right)tauright] , dtau} \
&mathrel{phantom{=}} mp sin^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau
end{split} \
begin{split}
&= mp leftlbrace cancelto{1}{cos^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right] + sin^{2} left[ 2pileft( frac{k}{2}t^{2} + f_{1}t + varphiright)right]} rightrbrace \
&mathrel{phantom{=}} int_{0}^{t} s_{i}left( tauright) sin left[ 2pileft( kt + f_{1}right)tauright] , dtau
end{split} \
&= tikzmarknode[cancel=red]{cc}{mp int_{0}^{t} s_{i}left( tauright) sin
left[ 2pileft( kt + f_{1}right)tauright] , dtau}
end{align}
%
end{document}
Off-topic but I would typeset the differential d
s that appear in the integrals upright.
answered 2 days ago
marmot
76.1k486160
76.1k486160
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f460267%2fneed-help-to-create-a-more-flexible-cancel-command-that-works-inside-an-align-e%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown