Color functional groups in chemfig syntaxChemfig: colour entire atom or section of atomFill the background of...

How do we objectively assess if a dialogue sounds unnatural or cringy?

Deal the cards to the players

The past tense for the quoting particle って

Why would /etc/passwd be used every time someone executes `ls -l` command?

If nine coins are tossed, what is the probability that the number of heads is even?

Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?

What is the oldest European royal house?

Why would the IRS ask for birth certificates or even audit a small tax return?

SHA 256 Algorithm

TikZ rotated text looks washed

PTIJ: Aliyot for the deceased

Why are special aircraft used for the carriers in the United States Navy?

What is better: yes / no radio, or simple checkbox?

What does "rhumatis" mean?

I can't die. Who am I?

Rationale to prefer local variables over instance variables?

When to use the term transposed instead of modulation?

Do natural melee weapons (from racial traits) trigger Improved Divine Smite?

Is this lemma equivalent to the axiom of choice?

Is there a way to find out the age of climbing ropes?

I've given my players a lot of magic items. Is it reasonable for me to give them harder encounters?

Where do you go through passport control when transiting through another Schengen airport on your way out of the Schengen area?

An Undercover Army

What can I do if someone tampers with my SSH public key?



Color functional groups in chemfig syntax


Chemfig: colour entire atom or section of atomFill the background of functional groups in chemfigFill the background of functional groups in chemfigIn chemfig, grouping with color ineffective, unlike textcolorUsing the mhchem and chemfig packages in conjunctionScale chemfig molecule in beamer with tikzchemfig double bond gap at jointHow to apply colour options to the contents of TikZ nodes when the content includes sbox{}usebox{}?Conflict in chemfig between cap=round and cram bondsChemfig: color doesn't workchemfig: NAD+ chemical structurechemfig: molecule vibration













9















I want to color simple functional groups in organic molecules using the chemfig package. I've come up with a solution that achieves what I want (MWE), but I find it very cumbersome. I thought it could be possible to wrap an entire group in one single color-statement. This question about colouring the background of a group of atoms in chemfig also gives a neat graphical emphasis of a group of atoms.



Is my solution, and the solution to the question above, the easiest way to colour or mark groups of atoms (including bonds) in chemfig? Just now, I don't have a need to easily reproduce loads of coloured functional groups, but I would like to know if there are easier ways to solve this problem without predefining macros for each group.



I believe I understand that the underlying problem is the way chemfig uses TikZ nodes to draw the structures, but I can't help to think that there should be a way to define some color environment that applies to all the TikZ nodes made by chemfig.



MWE:



documentclass{article}

usepackage{chemfig}

begin{document}
chemfig{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-{color{blue}C}(=[1,,,,blue] {color{blue}O})(-[7,,,,blue] {color{blue}OH})}
end{document}


Producing



enter image description here










share|improve this question

























  • I don't really have an answer but I'd probably really define macros or submols (depending on the wanted functionality)

    – clemens
    Feb 21 '15 at 18:50











  • I believe that what you did is the best you can do in chemfig at the moment.

    – pisoir
    Feb 25 '15 at 6:59
















9















I want to color simple functional groups in organic molecules using the chemfig package. I've come up with a solution that achieves what I want (MWE), but I find it very cumbersome. I thought it could be possible to wrap an entire group in one single color-statement. This question about colouring the background of a group of atoms in chemfig also gives a neat graphical emphasis of a group of atoms.



Is my solution, and the solution to the question above, the easiest way to colour or mark groups of atoms (including bonds) in chemfig? Just now, I don't have a need to easily reproduce loads of coloured functional groups, but I would like to know if there are easier ways to solve this problem without predefining macros for each group.



I believe I understand that the underlying problem is the way chemfig uses TikZ nodes to draw the structures, but I can't help to think that there should be a way to define some color environment that applies to all the TikZ nodes made by chemfig.



MWE:



documentclass{article}

usepackage{chemfig}

begin{document}
chemfig{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-{color{blue}C}(=[1,,,,blue] {color{blue}O})(-[7,,,,blue] {color{blue}OH})}
end{document}


Producing



enter image description here










share|improve this question

























  • I don't really have an answer but I'd probably really define macros or submols (depending on the wanted functionality)

    – clemens
    Feb 21 '15 at 18:50











  • I believe that what you did is the best you can do in chemfig at the moment.

    – pisoir
    Feb 25 '15 at 6:59














9












9








9


0






I want to color simple functional groups in organic molecules using the chemfig package. I've come up with a solution that achieves what I want (MWE), but I find it very cumbersome. I thought it could be possible to wrap an entire group in one single color-statement. This question about colouring the background of a group of atoms in chemfig also gives a neat graphical emphasis of a group of atoms.



Is my solution, and the solution to the question above, the easiest way to colour or mark groups of atoms (including bonds) in chemfig? Just now, I don't have a need to easily reproduce loads of coloured functional groups, but I would like to know if there are easier ways to solve this problem without predefining macros for each group.



I believe I understand that the underlying problem is the way chemfig uses TikZ nodes to draw the structures, but I can't help to think that there should be a way to define some color environment that applies to all the TikZ nodes made by chemfig.



MWE:



documentclass{article}

usepackage{chemfig}

begin{document}
chemfig{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-{color{blue}C}(=[1,,,,blue] {color{blue}O})(-[7,,,,blue] {color{blue}OH})}
end{document}


Producing



enter image description here










share|improve this question
















I want to color simple functional groups in organic molecules using the chemfig package. I've come up with a solution that achieves what I want (MWE), but I find it very cumbersome. I thought it could be possible to wrap an entire group in one single color-statement. This question about colouring the background of a group of atoms in chemfig also gives a neat graphical emphasis of a group of atoms.



Is my solution, and the solution to the question above, the easiest way to colour or mark groups of atoms (including bonds) in chemfig? Just now, I don't have a need to easily reproduce loads of coloured functional groups, but I would like to know if there are easier ways to solve this problem without predefining macros for each group.



I believe I understand that the underlying problem is the way chemfig uses TikZ nodes to draw the structures, but I can't help to think that there should be a way to define some color environment that applies to all the TikZ nodes made by chemfig.



MWE:



documentclass{article}

usepackage{chemfig}

begin{document}
chemfig{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-{color{blue}C}(=[1,,,,blue] {color{blue}O})(-[7,,,,blue] {color{blue}OH})}
end{document}


Producing



enter image description here







color best-practices chemfig






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 13 '17 at 12:36









Community

1




1










asked Feb 21 '15 at 10:20









HoleneHolene

3,93322858




3,93322858













  • I don't really have an answer but I'd probably really define macros or submols (depending on the wanted functionality)

    – clemens
    Feb 21 '15 at 18:50











  • I believe that what you did is the best you can do in chemfig at the moment.

    – pisoir
    Feb 25 '15 at 6:59



















  • I don't really have an answer but I'd probably really define macros or submols (depending on the wanted functionality)

    – clemens
    Feb 21 '15 at 18:50











  • I believe that what you did is the best you can do in chemfig at the moment.

    – pisoir
    Feb 25 '15 at 6:59

















I don't really have an answer but I'd probably really define macros or submols (depending on the wanted functionality)

– clemens
Feb 21 '15 at 18:50





I don't really have an answer but I'd probably really define macros or submols (depending on the wanted functionality)

– clemens
Feb 21 '15 at 18:50













I believe that what you did is the best you can do in chemfig at the moment.

– pisoir
Feb 25 '15 at 6:59





I believe that what you did is the best you can do in chemfig at the moment.

– pisoir
Feb 25 '15 at 6:59










1 Answer
1






active

oldest

votes


















7














Relate to this post.





documentclass{article}
usepackage{chemfig}
begin{document}
defRED{gdefprintatom##1{color{red}ensuremath{mathrm{##1}}}}
defBLACK{gdefprintatom##1{color{black}ensuremath{mathrm{##1}}}}
noindent
chemfig{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)(-[,,,,draw=none]RED)([,,,,,red]-[,,,,black]C(=[1]O)(-[7]OH))}BLACK \[1cm]
chemfig{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)(-C(=[1]O)(-[7]OH))}
end{document}


Where





  • [,,,,red] is to set the color of bonds within COOH.


  • [,,,,black] is to set the color of bond between C2H5 and COOH.


  • (-[,,,,draw=none]RED) is to create an ad hoc atom to change the color.


    • you can change the color anywhere, but sometimes it may cause bad spacing/positioning.

    • (e.g. chemfig reads RED COOH as five atoms, with the first atom having zero width.)








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%2f229363%2fcolor-functional-groups-in-chemfig-syntax%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









    7














    Relate to this post.





    documentclass{article}
    usepackage{chemfig}
    begin{document}
    defRED{gdefprintatom##1{color{red}ensuremath{mathrm{##1}}}}
    defBLACK{gdefprintatom##1{color{black}ensuremath{mathrm{##1}}}}
    noindent
    chemfig{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)(-[,,,,draw=none]RED)([,,,,,red]-[,,,,black]C(=[1]O)(-[7]OH))}BLACK \[1cm]
    chemfig{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)(-C(=[1]O)(-[7]OH))}
    end{document}


    Where





    • [,,,,red] is to set the color of bonds within COOH.


    • [,,,,black] is to set the color of bond between C2H5 and COOH.


    • (-[,,,,draw=none]RED) is to create an ad hoc atom to change the color.


      • you can change the color anywhere, but sometimes it may cause bad spacing/positioning.

      • (e.g. chemfig reads RED COOH as five atoms, with the first atom having zero width.)








    share|improve this answer






























      7














      Relate to this post.





      documentclass{article}
      usepackage{chemfig}
      begin{document}
      defRED{gdefprintatom##1{color{red}ensuremath{mathrm{##1}}}}
      defBLACK{gdefprintatom##1{color{black}ensuremath{mathrm{##1}}}}
      noindent
      chemfig{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)(-[,,,,draw=none]RED)([,,,,,red]-[,,,,black]C(=[1]O)(-[7]OH))}BLACK \[1cm]
      chemfig{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)(-C(=[1]O)(-[7]OH))}
      end{document}


      Where





      • [,,,,red] is to set the color of bonds within COOH.


      • [,,,,black] is to set the color of bond between C2H5 and COOH.


      • (-[,,,,draw=none]RED) is to create an ad hoc atom to change the color.


        • you can change the color anywhere, but sometimes it may cause bad spacing/positioning.

        • (e.g. chemfig reads RED COOH as five atoms, with the first atom having zero width.)








      share|improve this answer




























        7












        7








        7







        Relate to this post.





        documentclass{article}
        usepackage{chemfig}
        begin{document}
        defRED{gdefprintatom##1{color{red}ensuremath{mathrm{##1}}}}
        defBLACK{gdefprintatom##1{color{black}ensuremath{mathrm{##1}}}}
        noindent
        chemfig{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)(-[,,,,draw=none]RED)([,,,,,red]-[,,,,black]C(=[1]O)(-[7]OH))}BLACK \[1cm]
        chemfig{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)(-C(=[1]O)(-[7]OH))}
        end{document}


        Where





        • [,,,,red] is to set the color of bonds within COOH.


        • [,,,,black] is to set the color of bond between C2H5 and COOH.


        • (-[,,,,draw=none]RED) is to create an ad hoc atom to change the color.


          • you can change the color anywhere, but sometimes it may cause bad spacing/positioning.

          • (e.g. chemfig reads RED COOH as five atoms, with the first atom having zero width.)








        share|improve this answer















        Relate to this post.





        documentclass{article}
        usepackage{chemfig}
        begin{document}
        defRED{gdefprintatom##1{color{red}ensuremath{mathrm{##1}}}}
        defBLACK{gdefprintatom##1{color{black}ensuremath{mathrm{##1}}}}
        noindent
        chemfig{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)(-[,,,,draw=none]RED)([,,,,,red]-[,,,,black]C(=[1]O)(-[7]OH))}BLACK \[1cm]
        chemfig{H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)(-C(=[1]O)(-[7]OH))}
        end{document}


        Where





        • [,,,,red] is to set the color of bonds within COOH.


        • [,,,,black] is to set the color of bond between C2H5 and COOH.


        • (-[,,,,draw=none]RED) is to create an ad hoc atom to change the color.


          • you can change the color anywhere, but sometimes it may cause bad spacing/positioning.

          • (e.g. chemfig reads RED COOH as five atoms, with the first atom having zero width.)









        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Apr 13 '17 at 12:35









        Community

        1




        1










        answered Mar 3 '15 at 12:57









        Symbol 1Symbol 1

        25.3k240122




        25.3k240122






























            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%2f229363%2fcolor-functional-groups-in-chemfig-syntax%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

            Why does my Macbook overheat and use so much CPU and energy when on YouTube?Why do so many insist on using...

            How to prevent page numbers from appearing on glossaries?How to remove a dot and a page number in the...

            Puerta de Hutt Referencias Enlaces externos Menú de navegación15°58′00″S 5°42′00″O /...