Skip to content

@comment should be followed with delimiter #13

@zepinglee

Description

@zepinglee

A valid @comment command should be followed with a white space character, a comma, or a left brace. This is because BibTeX first scans for a identifier following @ (bibtex.web#L5433) and then determines if it's a comment (bibtex.web#L5465-L5470). Thus the comment rule should be 'comment' &[ \t\n{(].

See the following LaTeX test case.

\documentclass{article}
\begin{filecontents}[noheader,overwrite]{\jobname.bib}
@comment @book{test-comment-1,
  note = {The entry type is "book".}
}

@comment@book{test-comment-2,
  note = {The entry type is "comment@book".}
}
\end{filecontents}

\begin{filecontents}[noheader,overwrite]{\jobname.bst}
ENTRY { note } { } { }
FUNCTION {default.type}
{ "type: " type$ * top$
  "key: " cite$ * top$
}
FUNCTION {book} {default.type}
FUNCTION {comment@book} {default.type}
READ
ITERATE {call.type$}
\end{filecontents}

\begin{document}
\nocite{*}
\bibliographystyle{\jobname}
\bibliography{\jobname}
\end{document}

BibTeX treats comment@book as the entry type.

This is BibTeX, Version 0.99d (TeX Live 2023)
The top-level auxiliary file: main.aux
The style file: main.bst
Database file #1: main.bib
type: book
key: test-comment-1
type: comment@book
key: test-comment-2

BTW, there are duplicated rules named comment and they can be distinguished as "implicit comment" and "comment command".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions