162

Basic question (though I haven't found it here):

How do I comment out parts (some lines within an entry which I would like to save for later) of a BibTex file?

Apparently, @ can be used to comment out lines (but not be used within a comment itself), but only outside an entry, you have to move the commented lines out of the entry they belong to). Is there any other way?

153

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, which is why the above works; only what appears between the braces like in

@ENTRY{...
  ...
}

is considered. However, it should be noted that Biber is stricter than BibTeX in this respect, so it will warn about what it considers junk between entries. Adding a % at the beginning of a line turns off Biber's warnings.

  • 43
    Good. Now '//' before a line is treated as commented out. – Peng Zhang Jan 23 '14 at 21:03
  • 3
    For me, using // with TeXstudio and biber puts it into a never ending compile loop. However, I can put % before a line and it won't appear in the bibliography, see this answer, but unfortunately TeXstudio's color highlighting won't make it grey out like a comment. – Travis Bemrose Sep 3 '16 at 0:50
9

Emacs uses the prefix '@Comment' when using the "comment-or-uncomment-region" command in a BibTex file. This works on any line (at least in my version).

Using '%' also works for me, but I remember having it not work once -- I guess it may not be the most compatible.

Otherwise, you can achieve a similar effect to commenting out by changing the strings: (1) Change the key of a whole bibtex entry to something else, or (2) change the name of a BibTex field, as BibTex ignores field it doesn't know. In particular, I often "comment out" fields by prepending an underscore to the field name, e.g., I include

_pages = { TODO },

to mark that I should add the page number later.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.