What is the difference between textcolor and color?












14















I would like to define a new command to work as an alert command. If I want to alert some part of my text I would simply write alert{}. But I want the result in red color.



What is the best way to do this? I tried



defalert#1{{color{red}{#1}}}


but I know that there is textcolor also. I want my command to work both for text and math contents.



What is the difference between them?










share|improve this question



























    14















    I would like to define a new command to work as an alert command. If I want to alert some part of my text I would simply write alert{}. But I want the result in red color.



    What is the best way to do this? I tried



    defalert#1{{color{red}{#1}}}


    but I know that there is textcolor also. I want my command to work both for text and math contents.



    What is the difference between them?










    share|improve this question

























      14












      14








      14


      1






      I would like to define a new command to work as an alert command. If I want to alert some part of my text I would simply write alert{}. But I want the result in red color.



      What is the best way to do this? I tried



      defalert#1{{color{red}{#1}}}


      but I know that there is textcolor also. I want my command to work both for text and math contents.



      What is the difference between them?










      share|improve this question














      I would like to define a new command to work as an alert command. If I want to alert some part of my text I would simply write alert{}. But I want the result in red color.



      What is the best way to do this? I tried



      defalert#1{{color{red}{#1}}}


      but I know that there is textcolor also. I want my command to work both for text and math contents.



      What is the difference between them?







      color






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 8 '12 at 0:25









      SigurSigur

      25.8k457140




      25.8k457140






















          1 Answer
          1






          active

          oldest

          votes


















          31














          Despite the name textcolor also works in math mode. The main difference is just one of syntax, textcolor takes text as an argument (like textrm) color affects all text to the end of the group (like rmfamily). However textcolor also executes leavevmode which makes the color special occur in a much less destructive place as part of the paragraph rather than on a vertical list. So textcolor is usually a better choice unless you are setting a colour for a large amount of text, such as the whole document.






          share|improve this answer
























          • Thanks. I noticed that color package is required. Is there some color commands which needs only basic packages?

            – Sigur
            Dec 8 '12 at 0:38






          • 6





            There is basic underlying support for colour in the latex format but no actual top level colour commands. color is part of the required latex distribution so it is as basic as say article.cls

            – David Carlisle
            Dec 8 '12 at 0:39













          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%2f86039%2fwhat-is-the-difference-between-textcolor-and-color%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









          31














          Despite the name textcolor also works in math mode. The main difference is just one of syntax, textcolor takes text as an argument (like textrm) color affects all text to the end of the group (like rmfamily). However textcolor also executes leavevmode which makes the color special occur in a much less destructive place as part of the paragraph rather than on a vertical list. So textcolor is usually a better choice unless you are setting a colour for a large amount of text, such as the whole document.






          share|improve this answer
























          • Thanks. I noticed that color package is required. Is there some color commands which needs only basic packages?

            – Sigur
            Dec 8 '12 at 0:38






          • 6





            There is basic underlying support for colour in the latex format but no actual top level colour commands. color is part of the required latex distribution so it is as basic as say article.cls

            – David Carlisle
            Dec 8 '12 at 0:39


















          31














          Despite the name textcolor also works in math mode. The main difference is just one of syntax, textcolor takes text as an argument (like textrm) color affects all text to the end of the group (like rmfamily). However textcolor also executes leavevmode which makes the color special occur in a much less destructive place as part of the paragraph rather than on a vertical list. So textcolor is usually a better choice unless you are setting a colour for a large amount of text, such as the whole document.






          share|improve this answer
























          • Thanks. I noticed that color package is required. Is there some color commands which needs only basic packages?

            – Sigur
            Dec 8 '12 at 0:38






          • 6





            There is basic underlying support for colour in the latex format but no actual top level colour commands. color is part of the required latex distribution so it is as basic as say article.cls

            – David Carlisle
            Dec 8 '12 at 0:39
















          31












          31








          31







          Despite the name textcolor also works in math mode. The main difference is just one of syntax, textcolor takes text as an argument (like textrm) color affects all text to the end of the group (like rmfamily). However textcolor also executes leavevmode which makes the color special occur in a much less destructive place as part of the paragraph rather than on a vertical list. So textcolor is usually a better choice unless you are setting a colour for a large amount of text, such as the whole document.






          share|improve this answer













          Despite the name textcolor also works in math mode. The main difference is just one of syntax, textcolor takes text as an argument (like textrm) color affects all text to the end of the group (like rmfamily). However textcolor also executes leavevmode which makes the color special occur in a much less destructive place as part of the paragraph rather than on a vertical list. So textcolor is usually a better choice unless you are setting a colour for a large amount of text, such as the whole document.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 8 '12 at 0:32









          David CarlisleDavid Carlisle

          494k4111371885




          494k4111371885













          • Thanks. I noticed that color package is required. Is there some color commands which needs only basic packages?

            – Sigur
            Dec 8 '12 at 0:38






          • 6





            There is basic underlying support for colour in the latex format but no actual top level colour commands. color is part of the required latex distribution so it is as basic as say article.cls

            – David Carlisle
            Dec 8 '12 at 0:39





















          • Thanks. I noticed that color package is required. Is there some color commands which needs only basic packages?

            – Sigur
            Dec 8 '12 at 0:38






          • 6





            There is basic underlying support for colour in the latex format but no actual top level colour commands. color is part of the required latex distribution so it is as basic as say article.cls

            – David Carlisle
            Dec 8 '12 at 0:39



















          Thanks. I noticed that color package is required. Is there some color commands which needs only basic packages?

          – Sigur
          Dec 8 '12 at 0:38





          Thanks. I noticed that color package is required. Is there some color commands which needs only basic packages?

          – Sigur
          Dec 8 '12 at 0:38




          6




          6





          There is basic underlying support for colour in the latex format but no actual top level colour commands. color is part of the required latex distribution so it is as basic as say article.cls

          – David Carlisle
          Dec 8 '12 at 0:39







          There is basic underlying support for colour in the latex format but no actual top level colour commands. color is part of the required latex distribution so it is as basic as say article.cls

          – David Carlisle
          Dec 8 '12 at 0:39




















          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%2f86039%2fwhat-is-the-difference-between-textcolor-and-color%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