216

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?

2 Answers2

192

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.

egreg
  • 1,121,712
  • 47
    Good. Now '//' before a line is treated as commented out. – Peng Zhang Jan 23 '14 at 21:03
  • 4
    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 03 '16 at 00:50
20

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.

  • 2
    Yeah, I put "comments" with % in bibtex in Overleaf, and they were coloured gray. However, I started getting errors from "commented out entries". So % - comments work great outside entries. – Tomasz Gandor Mar 28 '20 at 09:53
  • I have done something like this - @article{.... year = "2018", Comment ="not important- you can delete this citation"} – PoreyS Aug 02 '22 at 19:26