152

You can "comment" whole entries by erasing the @ in front of the type declaration (@book -> book); there are no other ways of commenting parts of entries. However, unknown fields are ignored, so you can say OPTpages={34--35}, in order to ignore the pages field. Also repeated fields are ignored. As a matter of fact, text between entries will be ignored, ...


148

Following the C code paradigm, where one can use the preprocessor directives #if 0 junk code #endif something similar can be done in TeX (and descendants): \iffalse I don't want this to happen \fi The commented parts can be easily activated by replacing \iffalse with \iftrue.


111

The directives are understood by TeXShop, TeXWorks and TexStudio. The TS stands for TeXShop which was the IDE that first implemented them on the Mac. (Other editors have similar kinds of metadata). I'll comment on each directive separately, since I think they are not equally useful. My comments apply in principle to both TeXShop and TeXworks. J.C. ...


81

Use the verbatim package. \documentclass{article} \usepackage{verbatim} \begin{document} \begin{comment} some comment \someundefinedcommand \end{comment} a \end{document}


75

You are interested in the \note command. Please refer to Section 19 Adding Notes for Yourself of the beamer manual. A little example (taken from the manual): \documentclass{beamer} %\setbeameroption{show notes} un-comment to see the notes \begin{document} \begin{frame} \begin{itemize} \item<1-> Eggs \item<2-> Plants \note[item]<2&...


71

Another option is the comment package, which, like verbatim provides a comment environment, but offers the option to define arbitrary "throw away" environments that can selectively be enabled or disabled: \documentclass{article} \usepackage{comment} % uncomment to include stuff in standard comment-environment %\includecomment{comment} % define a mysection ...


70

Combining results from the questions cited in my comments... namely, doncherry's use of the fts "Teen Spirit" font (http://www.tug.dk/FontCatalogue/teenspirit/) referenced at How do I make my document look like it was written by a Cthulhu-worshipping madman?. I also used my answer at What are the ways to position things absolutely on the page? Below, I ...


64

Anything that is not inside a recognized entry is a comment. So just type along! Any .bib interpreter that complains about it is buggy, as it is not following the rules laid down in btxdoc. However, you can use an entry like @COMMENT, which will hopefully not trigger any complains.


61

Of course, you can always use the standard method, placing % before each line, to convert some text into a comment. But if you have tons of comments about contents that at some time you prefer to show in the PDF (for example, in a draft to your thesis supervisor) and you want to distinguish of comments to understand the next piece of LaTeX codes or disable ...


50

No, but you can define something close: \documentclass{article} \begin{document} \long\def\/*#1*/{} AAA \/* This is a test and this is another */ BBB \end{document}


49

In fact, only spaces which would be output have to be removed by comment. And remember, spaces after a all-letter control sequence (also known as a control word as opposed to a control symbol) are ignored. You can use: \usepackage [ left = 3cm, right = 3cm ] {geometry} It's Okey, no spaces will be output. But you have to use: \newcommand\foo {% the ...


47

To comment several lines at once in TeXMaker, select the lines and click Ctrl+T. To uncomment, click Ctrl+U. Edit To follow up on Torbjørn's comment, you can see the mostly used keyboard shortcuts under menu Edit > Comment You will see all of the default keyboard shortcuts and customize your keyboard shortcuts under menu Options > Configure ...


44

Instead \ifx true false you may use the shorter \iffalse dsaads fdfdfds \fi If you ever want to have to 'activate' your comments later, you may define your own if: \documentclass{article} \newif\ifcomment %\commenttrue # Show comments \begin{document} b \ifcomment dsaads fdfdfds \fi a \end{document} But I would not recommend the \ifcomment. There are ...


42

There are other ways to solve this problem than via (La)TeX. You can use your editor's capabilities for commenting to comment out large sections. For instance, in Emacs C-c ; comments (or uncomments) the region (see e.g. http://www.gnu.org/software/auctex/manual/auctex/Commenting.html#Commenting for details). You can use version control so that you may ...


37

Many classes and packages are written using docstrip which strips all normal comments from the file and can combine or split material to different files. Comments with two percent characters are called meta-characters and are not stripped but written directly to the class or package file itself. Therefore you won't find full-line single-% comments in these ...


36

I'd add some remarks to the nice answer by Leo Liu. Let's take a line from a package (it's not important to know which one) \newcommand{\period@active}[1]{\begingroup\mathcode`\.="8000\ensuremath{#1}\endgroup} This shows a common mistake that in the present example is actually innocuous, but only by chance, because \ensuremath expands to \protect\...


36

Editors that understand % ! TeX directives E P R S TeXShop x x x x TeXStudio x x x x TextMate ? x x ? TeXworks x x x x SublimeText o x x x Atom o x x o Vim (vimtex) o x x o Overleaf ? x ? ? | | | | x = yes | | | Spellcheck o = no | | Root ? = ? | Program ...


33

There's no built-in different behavior between %% and %; but as a consequence of how the docstrip works in extracting the code from a documented source .dtx file, usually the prolog and the final lines start with %%. Of course one can use differently marked lines for preprocessing, but from a pure TeX point of view, those lines are perfectly equivalent. I ...


30

You can do this: \newcommand{\cmmnt}[1]{} ... \begin{document} Hello \cmmnt{commented text} bye. \end{document} A comment suggests eliminating undesired spaces around the comment: \newcommand{\cmmnt}[1]{\ignorespaces} ... (This should be part of some "comment" package, if it is not already.)


29

The answer to your question is two fold: Yes, comments are ignored when compiling and the text of a comment is irrecoverable from the final document. However, no. It is often possible to tell where / how long the comments in the source were. For instance, take the following senario: Line 1 Line 2 vs. Line 1% Line 2 In the compiled output, the newline ...


28

latexpand (distributed with TeXLive) latexpand is a tool to expand include/input directives which also removes comments. It can also be tweaked to keep end-of-line comments because sometimes they are meaningful. In a second step remove lines with only %: $ latexpand --empty-comments mytexfile.tex > mytexfile-stripped.tex Remove lines with only % and ...


27

The following is for people who have the stable version of TeXLive which ships out with version 1.8 of fancytooltips. (For newer versions and other TeX distributions see below.) Here is a possibility using fancytooltips package by robert.marik.cz, who is also a regular in this site. See also related topic: Showing the bibliographic entry in a popup when ...


27

At least with biber, you should be able to use the same commenting method as with LaTeX, that is using % for the commented line. After a few test comments can be outside entries, within entries (commenting a whole line) or commenting the end of a line. %%%%%%%%%%% % PREPRINT @article{myarticle, author = {Onymous, A. N.}, %The author % the title of ...


26

Like almost all programming languages, comment interpretation happens after tokenization. \ta% produces the token \ta which will then fail to expand and genenerate an error before the u is seen at all. this is no different from C or javascrpt etc where you can not use a comment in the middle of a function name, or XML/HTML where you can not use a comment ...


25

Alan Munn’s answer covered most of the questions for TeXShop; I’ll explain them for TeXworks. (This is adapted from Joseph Wright’s blog post TeXworks ‘magic comments’.) % !TeX program =〈program〉: 〈program〉 should be one of the programs set up in TeXworks and is case-insensitive. (Note that the “TS-” in TS-program is optional in TeXworks.) % !TeX encoding =...


21

The problem is in how comments.sty writes out files; when you input à, it is interpreted during a \write and it becomes the character corresponding to à in the T1 encoding. Solution: modify \ThisComment to write out uninterpreted commands. \documentclass{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc}%this file is stored as UTF8 file! \...


19

A solution I use is the following: I defined a command to write my comments in: \newcommand{\rood}[1]{\textcolor{red}{[#1]}} %for displaying red texts ("rood" is Dutch for "red"). A comment looks like this: \rood{This comment is displayed in red} When I want to create my final version, I simply remove the second part of this comment, meaning that all ...


19

As mentioned already in the comments you can use escapeinside option of lstlisting (listings package) to execute own code inside a code listing. There are also executebegin and executeend to insert code automatically before and after such markers. My idea: * Use minipages to restrain the listing to less than the text width and move it to the right using ...


19

Donald E. Knuth not only gave us TeX, he can also be considered the father of literate programming. The principle of literate programming is also applied when preparing a package for LaTeX. A .dtx file contains an explanation of the macros in plain English comments whilst being interspersed with snippets of the real macros in LaTeX code. From this .dtx file,...


18

A similar solution I came up with is to define a \comment command: \newcommand{\comment}[1]{} The command makes LaTeX ignore anything inside. This solution has the advantage over the other solutions (for me) of being a command rather than an environment with \begin/\end commands. Usage: Text that will be in the final document. \comment{I am thinking of ...


Only top voted, non community-wiki answers of a minimum length are eligible