168

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.


118

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. ...


85

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 ...


82

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&...


77

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 ...


71

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.


66

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 ...


51

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

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 ...


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 ...


40

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 ...


35

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 ...


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 ...


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 =...


25

A simple solution I use is \newcommand{\comment}[1]{} Which just defines a command that does nothing with the input (effectively commenting it out!) Sample use: \comment{ This line of text won't show This one won't either }


24

You could use a so-called “meta-comment”, something like this: This is typeset. \iffalse This is not. \fi This is typeset again. Note the position of the spaces.


21

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 ...


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

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,...


19

It is in no way discouraged to comment any files you might have written. What you came across is a slight discrepancy in the handling of comments, or if you will a disagreement about what constitutes a comment. According to btxdoc, §4, item 7, p. 13 BibTeX allows in the database files any comment that's not within an entry. If you want to comment out an ...


19

As TeX reads your file, it maintains a state which can be one of these three: State N (for new_line): This is the state in which TeX starts at the beginning of each line in the input. State M (for mid_line): This is the most common state State S (for skip_blanks): This is like State M, except that blanks are ignored. Among other things (see more details in ...


18

It's consistent with the rules. When TeX finds an end-of-record marker (end of line, if you prefer) as determined by the operating system, it throws it away together with possible trailing spaces and tabs; it then appends the current \endlinechar, usually ASCII 13 (represented in TeX as ^^M). At this stage, tokenization has not yet taken place. Now ...


18

LaTeX/TeX do not support mid-line comments. the % character will start a comment which will end at the start of the new line. What you can do is split your lines, like so Start your % text this way


17

LaTeX is a markup language. For the private information macros can be used. File exercise.435.tex could look like: \private{is the \filename{exercise.435.tex}} \private{1.84 ex.\@ 127 page notes} \begin{exercise} ... \end{exercise} Then macro \private can be defined to set the contents in red and small font: \newcommand*{\private}[1]{% \ifhmode\newline\...


16

I often paste in plain text such as writing guidelines and comment them out. For me the simplest way is to define a command with an argument which produces no output. \newcommand{\comm}[1]{} And to comment out text: \comm{ Text text text }


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