Check if mmode Command Doesn't Work in Tikz-cd environment












2















I have a command that allows me to write terminal in math mode and it print in its bb-bold style, but also allows me to call it in text mode as terminal (as opposed to (terminal) or whatever). The math font I've used is a result of the difficulty of finding nice look bb-bold characters for 0 and 1 as initial and terminal objects (category theory).



However, I think the check breaks down when the command is called in a tikz-cd environment causing me to get a lot of errors (missing delimiters, missing math mode, math font called in text mode, etc.). is there an easy fix that allows me to continue using the same terminal command in and out of math mode?



documentclass[a4paper, 12pt]{article}
usepackage[utf8]{inputenc}

DeclareMathAlphabet{mymathbb}{U}{BOONDOX-ds}{m}{n}
newcommand{terminal}{ifmmodemymathbb{1}else$mymathbb{1}$fi}

begin{document}

begin{figure}
centering
begin{tikzcd}[column sep=huge, row sep=huge]
F rar["eta", squiggly, tail] dar["!", squiggly] & G dar["chi_eta", squiggly] \
terminal rar["top", squiggly] & Omega
end{tikzcd}
end{figure}

end{document}









share|improve this question























  • You gain nothing by defining terminal so that it works in text mode: you'd need terminal{} if you use it in text, and $terminal$ is the same number of keys and clearer because it segregates math. Anyway, if you want to roll on your own version of ensuremath, add relax in front of ifmmode. See tex.stackexchange.com/q/34830/4427

    – egreg
    Jan 18 at 18:35








  • 1





    Also, I find arrow[r,"eta"] much clearer than the obscure rar.

    – egreg
    Jan 18 at 18:36













  • @egreg I type terminal and it prints fine. I know it sounds silly but typing the dollar signs slows me down and the accepted answer provides an easy enough macro to avoid that necessity. Thanks for the feedback though. EDIT: to your second comment, I currently have some 50 commutative diagrams in this document, and the time saving of using shortcuts like rar or ular is worth the sacrifice in readability (to me).

    – Ben
    Jan 19 at 19:03


















2















I have a command that allows me to write terminal in math mode and it print in its bb-bold style, but also allows me to call it in text mode as terminal (as opposed to (terminal) or whatever). The math font I've used is a result of the difficulty of finding nice look bb-bold characters for 0 and 1 as initial and terminal objects (category theory).



However, I think the check breaks down when the command is called in a tikz-cd environment causing me to get a lot of errors (missing delimiters, missing math mode, math font called in text mode, etc.). is there an easy fix that allows me to continue using the same terminal command in and out of math mode?



documentclass[a4paper, 12pt]{article}
usepackage[utf8]{inputenc}

DeclareMathAlphabet{mymathbb}{U}{BOONDOX-ds}{m}{n}
newcommand{terminal}{ifmmodemymathbb{1}else$mymathbb{1}$fi}

begin{document}

begin{figure}
centering
begin{tikzcd}[column sep=huge, row sep=huge]
F rar["eta", squiggly, tail] dar["!", squiggly] & G dar["chi_eta", squiggly] \
terminal rar["top", squiggly] & Omega
end{tikzcd}
end{figure}

end{document}









share|improve this question























  • You gain nothing by defining terminal so that it works in text mode: you'd need terminal{} if you use it in text, and $terminal$ is the same number of keys and clearer because it segregates math. Anyway, if you want to roll on your own version of ensuremath, add relax in front of ifmmode. See tex.stackexchange.com/q/34830/4427

    – egreg
    Jan 18 at 18:35








  • 1





    Also, I find arrow[r,"eta"] much clearer than the obscure rar.

    – egreg
    Jan 18 at 18:36













  • @egreg I type terminal and it prints fine. I know it sounds silly but typing the dollar signs slows me down and the accepted answer provides an easy enough macro to avoid that necessity. Thanks for the feedback though. EDIT: to your second comment, I currently have some 50 commutative diagrams in this document, and the time saving of using shortcuts like rar or ular is worth the sacrifice in readability (to me).

    – Ben
    Jan 19 at 19:03
















2












2








2








I have a command that allows me to write terminal in math mode and it print in its bb-bold style, but also allows me to call it in text mode as terminal (as opposed to (terminal) or whatever). The math font I've used is a result of the difficulty of finding nice look bb-bold characters for 0 and 1 as initial and terminal objects (category theory).



However, I think the check breaks down when the command is called in a tikz-cd environment causing me to get a lot of errors (missing delimiters, missing math mode, math font called in text mode, etc.). is there an easy fix that allows me to continue using the same terminal command in and out of math mode?



documentclass[a4paper, 12pt]{article}
usepackage[utf8]{inputenc}

DeclareMathAlphabet{mymathbb}{U}{BOONDOX-ds}{m}{n}
newcommand{terminal}{ifmmodemymathbb{1}else$mymathbb{1}$fi}

begin{document}

begin{figure}
centering
begin{tikzcd}[column sep=huge, row sep=huge]
F rar["eta", squiggly, tail] dar["!", squiggly] & G dar["chi_eta", squiggly] \
terminal rar["top", squiggly] & Omega
end{tikzcd}
end{figure}

end{document}









share|improve this question














I have a command that allows me to write terminal in math mode and it print in its bb-bold style, but also allows me to call it in text mode as terminal (as opposed to (terminal) or whatever). The math font I've used is a result of the difficulty of finding nice look bb-bold characters for 0 and 1 as initial and terminal objects (category theory).



However, I think the check breaks down when the command is called in a tikz-cd environment causing me to get a lot of errors (missing delimiters, missing math mode, math font called in text mode, etc.). is there an easy fix that allows me to continue using the same terminal command in and out of math mode?



documentclass[a4paper, 12pt]{article}
usepackage[utf8]{inputenc}

DeclareMathAlphabet{mymathbb}{U}{BOONDOX-ds}{m}{n}
newcommand{terminal}{ifmmodemymathbb{1}else$mymathbb{1}$fi}

begin{document}

begin{figure}
centering
begin{tikzcd}[column sep=huge, row sep=huge]
F rar["eta", squiggly, tail] dar["!", squiggly] & G dar["chi_eta", squiggly] \
terminal rar["top", squiggly] & Omega
end{tikzcd}
end{figure}

end{document}






macros tikz-cd






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 18 at 17:07









BenBen

326




326













  • You gain nothing by defining terminal so that it works in text mode: you'd need terminal{} if you use it in text, and $terminal$ is the same number of keys and clearer because it segregates math. Anyway, if you want to roll on your own version of ensuremath, add relax in front of ifmmode. See tex.stackexchange.com/q/34830/4427

    – egreg
    Jan 18 at 18:35








  • 1





    Also, I find arrow[r,"eta"] much clearer than the obscure rar.

    – egreg
    Jan 18 at 18:36













  • @egreg I type terminal and it prints fine. I know it sounds silly but typing the dollar signs slows me down and the accepted answer provides an easy enough macro to avoid that necessity. Thanks for the feedback though. EDIT: to your second comment, I currently have some 50 commutative diagrams in this document, and the time saving of using shortcuts like rar or ular is worth the sacrifice in readability (to me).

    – Ben
    Jan 19 at 19:03





















  • You gain nothing by defining terminal so that it works in text mode: you'd need terminal{} if you use it in text, and $terminal$ is the same number of keys and clearer because it segregates math. Anyway, if you want to roll on your own version of ensuremath, add relax in front of ifmmode. See tex.stackexchange.com/q/34830/4427

    – egreg
    Jan 18 at 18:35








  • 1





    Also, I find arrow[r,"eta"] much clearer than the obscure rar.

    – egreg
    Jan 18 at 18:36













  • @egreg I type terminal and it prints fine. I know it sounds silly but typing the dollar signs slows me down and the accepted answer provides an easy enough macro to avoid that necessity. Thanks for the feedback though. EDIT: to your second comment, I currently have some 50 commutative diagrams in this document, and the time saving of using shortcuts like rar or ular is worth the sacrifice in readability (to me).

    – Ben
    Jan 19 at 19:03



















You gain nothing by defining terminal so that it works in text mode: you'd need terminal{} if you use it in text, and $terminal$ is the same number of keys and clearer because it segregates math. Anyway, if you want to roll on your own version of ensuremath, add relax in front of ifmmode. See tex.stackexchange.com/q/34830/4427

– egreg
Jan 18 at 18:35







You gain nothing by defining terminal so that it works in text mode: you'd need terminal{} if you use it in text, and $terminal$ is the same number of keys and clearer because it segregates math. Anyway, if you want to roll on your own version of ensuremath, add relax in front of ifmmode. See tex.stackexchange.com/q/34830/4427

– egreg
Jan 18 at 18:35






1




1





Also, I find arrow[r,"eta"] much clearer than the obscure rar.

– egreg
Jan 18 at 18:36







Also, I find arrow[r,"eta"] much clearer than the obscure rar.

– egreg
Jan 18 at 18:36















@egreg I type terminal and it prints fine. I know it sounds silly but typing the dollar signs slows me down and the accepted answer provides an easy enough macro to avoid that necessity. Thanks for the feedback though. EDIT: to your second comment, I currently have some 50 commutative diagrams in this document, and the time saving of using shortcuts like rar or ular is worth the sacrifice in readability (to me).

– Ben
Jan 19 at 19:03







@egreg I type terminal and it prints fine. I know it sounds silly but typing the dollar signs slows me down and the accepted answer provides an easy enough macro to avoid that necessity. Thanks for the feedback though. EDIT: to your second comment, I currently have some 50 commutative diagrams in this document, and the time saving of using shortcuts like rar or ular is worth the sacrifice in readability (to me).

– Ben
Jan 19 at 19:03












1 Answer
1






active

oldest

votes


















2














ensuremath does what your ifmmode intends to do.



documentclass[a4paper, 12pt]{article}
usepackage{tikz-cd}
usetikzlibrary{decorations.pathmorphing}
usepackage[utf8]{inputenc}

DeclareMathAlphabet{mymathbb}{U}{BOONDOX-ds}{m}{n}
newcommand{terminal}{ensuremath{mymathbb{1}}}

begin{document}

begin{figure}
centering
begin{tikzcd}[column sep=huge, row sep=huge]
F rar["eta", squiggly] & G dar["chi_eta", squiggly] \
terminal
rar["true", squiggly] & Omega
end{tikzcd}
end{figure}

end{document}


enter image description here






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',
    autoActivateHeartbeat: false,
    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%2f470737%2fcheck-if-mmode-command-doesnt-work-in-tikz-cd-environment%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









    2














    ensuremath does what your ifmmode intends to do.



    documentclass[a4paper, 12pt]{article}
    usepackage{tikz-cd}
    usetikzlibrary{decorations.pathmorphing}
    usepackage[utf8]{inputenc}

    DeclareMathAlphabet{mymathbb}{U}{BOONDOX-ds}{m}{n}
    newcommand{terminal}{ensuremath{mymathbb{1}}}

    begin{document}

    begin{figure}
    centering
    begin{tikzcd}[column sep=huge, row sep=huge]
    F rar["eta", squiggly] & G dar["chi_eta", squiggly] \
    terminal
    rar["true", squiggly] & Omega
    end{tikzcd}
    end{figure}

    end{document}


    enter image description here






    share|improve this answer




























      2














      ensuremath does what your ifmmode intends to do.



      documentclass[a4paper, 12pt]{article}
      usepackage{tikz-cd}
      usetikzlibrary{decorations.pathmorphing}
      usepackage[utf8]{inputenc}

      DeclareMathAlphabet{mymathbb}{U}{BOONDOX-ds}{m}{n}
      newcommand{terminal}{ensuremath{mymathbb{1}}}

      begin{document}

      begin{figure}
      centering
      begin{tikzcd}[column sep=huge, row sep=huge]
      F rar["eta", squiggly] & G dar["chi_eta", squiggly] \
      terminal
      rar["true", squiggly] & Omega
      end{tikzcd}
      end{figure}

      end{document}


      enter image description here






      share|improve this answer


























        2












        2








        2







        ensuremath does what your ifmmode intends to do.



        documentclass[a4paper, 12pt]{article}
        usepackage{tikz-cd}
        usetikzlibrary{decorations.pathmorphing}
        usepackage[utf8]{inputenc}

        DeclareMathAlphabet{mymathbb}{U}{BOONDOX-ds}{m}{n}
        newcommand{terminal}{ensuremath{mymathbb{1}}}

        begin{document}

        begin{figure}
        centering
        begin{tikzcd}[column sep=huge, row sep=huge]
        F rar["eta", squiggly] & G dar["chi_eta", squiggly] \
        terminal
        rar["true", squiggly] & Omega
        end{tikzcd}
        end{figure}

        end{document}


        enter image description here






        share|improve this answer













        ensuremath does what your ifmmode intends to do.



        documentclass[a4paper, 12pt]{article}
        usepackage{tikz-cd}
        usetikzlibrary{decorations.pathmorphing}
        usepackage[utf8]{inputenc}

        DeclareMathAlphabet{mymathbb}{U}{BOONDOX-ds}{m}{n}
        newcommand{terminal}{ensuremath{mymathbb{1}}}

        begin{document}

        begin{figure}
        centering
        begin{tikzcd}[column sep=huge, row sep=huge]
        F rar["eta", squiggly] & G dar["chi_eta", squiggly] \
        terminal
        rar["true", squiggly] & Omega
        end{tikzcd}
        end{figure}

        end{document}


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 18 at 17:11









        marmotmarmot

        94.6k4109209




        94.6k4109209






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f470737%2fcheck-if-mmode-command-doesnt-work-in-tikz-cd-environment%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

            How to change which sound is reproduced for terminal bell?

            Can I use Tabulator js library in my java Spring + Thymeleaf project?

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents