Home > English, Linux & Programming > Conditional Commenting in LaTeX

Conditional Commenting in LaTeX

In my Ph.D. thesis are quite a lot of comments/reminders for myself. I defined two commands for this, one for a red footnote and one for red bold text. But if someone else is to read parts of the document, he shouldn’t necessarily see all my comments, so I was searching for a method to suppress all comments with a single flag. I found the package ifthen and it’s exactly what I was looking for. If you need to use comments for yourself in a document you’re writing, consider using the following:

% If set to true, comments will be inserted, otherwise ignored
% Internal command
% use \todo{text} for a comment within your page/section
\newcommand{\todo}[1]{\ifthenelse {\boolean{showComments}} {\todocmd{#1}} {}}
% use todof{text} for a footnote
\newcommand{\todof}[1]{\ifthenelse {\boolean{showComments}} {\footnote{\todocmd{#1}}} {}}
Categories: English, Linux & Programming Tags:
  1. Titus
    May 14th, 2009 at 15:37 | #1

    I think there are some “\” backslashes missing. I will figure it out where to put them

  2. May 14th, 2009 at 15:43 | #2

    Thanks for the hint! I will test it myself again (with time), if you see any problems, please do tell.

  3. Titus
    May 14th, 2009 at 15:57 | #3

    I tried

    % If set to true, comments will be inserted, otherwise ignored
    % Internal command
    % use todo{text} for a comment within your page/section
    \newcommand{\todo}[1]{\ifthenelse {\boolean{showComments}} {\todocmd{#1}} {}}


    but I get

    ! Undefined control sequence.
    \todocmd #1->{\bftextcolor
    l.113 \todo{xxxxx}

    still some error somewhere

  4. May 14th, 2009 at 16:15 | #4

    Indeed, the WordPress editor took away all backslashes, hopefully I added all. Also, the package {color} was missing, my mistake. Thanks for trying it out!
    You should change two things in your code to get it working:
    Add: \usepackage{color}
    Make a backslash between \bf and \textcolor in \newcommand{\todocmd}:

    Hope it’s running fine now and you find it useful. If there are any other problems, please let me know.

  5. Titus
    May 14th, 2009 at 16:21 | #5

    It works. Thanks a lot!

  6. Sebastian
    January 31st, 2011 at 16:08 | #6

    Thanks a lot Daniel. Works really good, no problems at all.

  7. monochromata
    April 27th, 2011 at 17:07 | #7


  8. July 29th, 2019 at 02:32 | #8

    Is Keflex A Type Of Penicillin [url=http://cialtadalaf.com]cheapest cialis 20mg[/url] Vendita Di Cialis Levitra Para La Mujer Valtrex Online Cheap

  9. August 1st, 2019 at 03:55 | #9

    Order Legally Stendra Overseas Mastercard best price on levitra Amoxicillin Effects On Liver Discount Propecia Propecia Help Proscar

  10. August 4th, 2019 at 00:40 | #10

    Baclofene Renaud De Beaurepaire Viagra Fa Bene viagra Levitra Affitto

  11. August 4th, 2019 at 10:34 | #11

    В мегаполисах и малых городах России Совкомбанк известен как надежный и выгодный финансовый партнер. Полный пакет лицензий и сертификатов позволяет Совкомбанку оказывать широкий спектр финансовых услуг.

    Миссия Банка – предоставлять каждому клиенту максимально возможный набор банковских услуг высокого качества и надежности, следуя мировым стандартам и принципам корпоративной этики. Наш Банк – это современный высокотехнологичный банк, сочетающий в себе новейшие технологии оказания услуг и лучшие традиции банковского сообщества и российского предпринимательства.

    Взять кредит по этой ссылке ===> http://v.ht/X3Qnq

  12. August 6th, 2019 at 18:53 | #12

    Viagra Efficace buy cialis online Clomid 5000

  13. August 14th, 2019 at 10:13 | #13

    I Want To Buy Alli! legally isotretinoin amex accepted Generic Viagra With American Express cheapest cialis Viagra Combien Sa Coute Cialis Et Viagra En Ligne

  14. August 16th, 2019 at 22:39 | #14

    Drug Without Script Online Order Clonidine Online Overnight cialis canada Cheap Effexor Cialis Propecia

  15. August 21st, 2019 at 18:32 | #15

    Acheter Pilule Propecia Macrobid Saturday Delivery Viagra Kaufen Deutschland viagra Kamagra Francia

  16. August 29th, 2019 at 20:40 | #16

    Achat Cialis Au Quebec Bonamine Discontinued cialis vs viagra Onlineviagraaustralia

  17. October 8th, 2019 at 17:36 | #17
  18. October 11th, 2019 at 16:16 | #18

    Tadalafil 20mg Lowest Price Viagra From Canada Legitimate Viagra Mg viagra Cephalexin Ibuprofen Propecia Castillo Viagra Rezeptfrei Kaufen Billig

  1. No trackbacks yet.