1

my question may be silly, but i have been into LaTeX for a while now, and all the commands i have encountered so far are either composed of pure letters, or letters and the "at" symbol --> @.

but when i was trying to customize my bibliographies using the amsrefs package, i noticed in the amsrefs.pdf documentation (version Version 2.14, 2013/03/07) that some commands have apostrophes, like \bib'author, \bib'editor, etc. may i kindly show the following MWE1:

\documentclass{article}
\usepackage[nobysame,author-year]{amsrefs}%
\makeatletter
\renewcommand*{\PrintEditorsA}[1]%
{%
\ifx\previous@primary\current@primary
\sameauthors{(Ed\Plural{s}.)}%
\else
\def\current@bibfield{\bib'editor}%
\PrintNames{}{ (Ed\Plural{s}.)}{#1}%
\fi%
\erase@field\bib'editor%
}%
\makeatother

\begin{document} \cite{mybookkey1} \begin{bibdiv} \begin{biblist} \bibselect{sampledb} \end{biblist} \end{bibdiv}

%contents of sampledb.ltb % %\documentclass{article} %\usepackage{amsrefs} %\begin{document} %\begin{bibdiv} %\begin{biblist} %\bib*{mykey-not-citable}{book}{ %editor={von Last1, First, Jr.}, %editor={von Last2, First, Jr.}, %editor={von Last3, First, Jr.}, %title={Title of Book}, %} %\bib{mybookkey1}{book}{ %xref={mykey-not-citable} %} %\end{biblist} %\end{bibdiv} %\end{document}

\end{document}

In this MWE1, I was trying to modify the definition of \PrintEditorsA (found on page 99 of amsrefs.pdf documentation) such that the "eds." will become "Eds." (it will become capitalized). For one reason or another, MWE1 is not compiling as is. However, when i commented out the lines containing \bib'editor, it is compiling already. but i'm sure that those lines are important, so i wouldn't want to comment out lines at random. Thus, it made me conclude that perhaps, the commands containing apostrophes (\bib'editor for example) are causing the problem. may I know my mistakes?

beethovengg14

Don Hosek
  • 14,078

2 Answers2

3

The use of ' in the names is to keep users from mucking about with those commands. If you look inside amsrefs.sty, you'll see that they set \catcode`\'=11 in the file to allow apostrophes in command names. Given this unusual setup, I'd be especially wary of mucking around with those commands. Have you looked at the user documentation for amsrefs (which should be amsrdoc.pdf)? It is likely more useful for your needs and there may be a user-level hook available to get the change that you need without having to dive into the internals of the package.

The Amplitwist
  • 71
  • 1
  • 18
Don Hosek
  • 14,078
  • 1
    thank you sir @donhasek for the reply. Yes, i did read through amsrdoc, from first page to last. All i just wanted is to customize the bibliographic fields to suit my own/or my publisher's needs. For example, in APA7th edition style, editors are "Eds." (capitalized), not "eds." Other publishers have other styles too. The authors of amsrefs and amsrdoc said that customization is possible by "redefining" functions and/or "devising" my own – beethovengg14 Jun 11 '21 at 04:46
3

The amsrefs.sty package indeed uses ' in command names, but it's not a big problem.

If you want to change “eds.” into “Eds.”, look for Editor in the package and you'll find reference to the macros \PrintEditorA, \PrintEditorB and \PrintEditorC, along with their definitions

\newcommand{\PrintEditorsC}[1]{%
    \PrintNames{Edited by }{}{#1}%
}
\newcommand{\PrintEditorsA}[1]{%
    \ifx\previous@primary\current@primary
        \sameauthors{(ed\Plural{s}.)}%
    \else
        \def\current@bibfield{\bib'editor}%
        \PrintNames{}{ (ed\Plural{s}.)}{#1}%
    \fi
    \erase@field\bib'editor
}
\newcommand{\PrintEditorsB}{%
    \PrintNames*{(}{\SwapBreak{,}~ed\Plural{s}.)}%
}

You can modify them in your document preamble by

\makeatletter
\catcode`'=11
\renewcommand{\PrintEditorsA}[1]{%
    \ifx\previous@primary\current@primary
        \sameauthors{(Ed\Plural{s}.)}%
    \else
        \def\current@bibfield{\bib'editor}%
        \PrintNames{}{ (Ed\Plural{s}.)}{#1}%
    \fi
    \erase@field\bib'editor
}
\newcommand{\PrintEditorsB}{%
    \PrintNames*{(}{\SwapBreak{,}~Ed\Plural{s}.)}%
}
\catcode`'=12
\makeatother

You could also do more briefly with patches:

\usepackage{etoolbox}

\catcode'=11 \patchcmd{\PrintEditorsA}{ed\Plural}{Ed\Plural}{}{} \patchcmd{\PrintEditorsA}{ed\Plural}{Ed\Plural}{}{} \patchcmd{\PrintEditorsB}{ed\Plural}{Ed\Plural}{}{} \catcode'=12

egreg
  • 1,121,712
  • wonderful sir! i will check your suggestions. im missing the lines \catcode ... – beethovengg14 Jun 11 '21 at 11:05
  • hi sir egreg. your solution worked! thank you very much! i was indeed missing the \catcode .. lines. though i still need to test the patchcmd solution. in the meantime, the catcode solution will do. thank you po sa inyo – beethovengg14 Jun 13 '21 at 23:24