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:




  1. Would it be possible to adapt the above-mentioned solution to work inside the align environment?


  2. 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:



enter image description here










share|improve this question




























    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:




    1. Would it be possible to adapt the above-mentioned solution to work inside the align environment?


    2. 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:



    enter image description here










    share|improve this question


























      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:




      1. Would it be possible to adapt the above-mentioned solution to work inside the align environment?


      2. 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:



      enter image description here










      share|improve this question















      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:




      1. Would it be possible to adapt the above-mentioned solution to work inside the align environment?


      2. 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:



      enter image description here







      tikz-pgf align cancel






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 days ago









      Dũng Vũ

      1,05018




      1,05018










      asked 2 days ago









      Joao Alberto

      995




      995






















          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}


          enter image description here



          Off-topic but I would typeset the differential ds that appear in the integrals upright.






          share|improve this answer





















            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "85"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            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

























            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}


            enter image description here



            Off-topic but I would typeset the differential ds that appear in the integrals upright.






            share|improve this answer

























              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}


              enter image description here



              Off-topic but I would typeset the differential ds that appear in the integrals upright.






              share|improve this answer























                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}


                enter image description here



                Off-topic but I would typeset the differential ds that appear in the integrals upright.






                share|improve this answer












                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}


                enter image description here



                Off-topic but I would typeset the differential ds that appear in the integrals upright.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 2 days ago









                marmot

                76.1k486160




                76.1k486160






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Accessing regular linux commands in Huawei's Dopra Linux

                    Can't connect RFCOMM socket: Host is down

                    Kernel panic - not syncing: Fatal Exception in Interrupt