0

I want to define a command that will automatically do the following:

\textbf{\citeasnoun{CITATION}}

So then I can just do:

\boldcite{CITATION}

I tried the following but it doesn't work

\def \boldcite{#1} \textbf{\citeasnoun{#1}}

I get an error about illegal parameter number (sorry, Latex doesn't let me copy and paste the console output for some odd reason)

cas5nq
  • 101
  • 1
    Welcome! What is \citeasnoun? It is sure not a standard command! \newcommand*\boldcite[1]{\textbf{\citeasnoun{#1}}. Untested as I have no clue what you're using. – cfr Nov 29 '15 at 04:23
  • 1
    See my answer on this topic. – cfr Nov 29 '15 at 04:24
  • \def\boldcite#1{\textbf{\citeasnoun{#1}} – Mark Nov 29 '15 at 07:55
  • 1
    @Mark You could do that. But you shouldn't. Better to use \newcommand* for the reasons outlined in the answer below or my linked answer. – cfr Nov 29 '15 at 14:23
  • True. I was trying to give the answer that minimized edit distance to the original attempted solution. – Mark Nov 30 '15 at 05:05

1 Answers1

3

The syntax should look like this.

\newcommand{\boldcite}[1]{\textbf{\citeasnoun{#1}}

In a \newcommand declaration, you use [1] to indicate a mandatory argument, [2] to indicate two arguments, and so on, and then refer to them as #1 and #2 in the command text.

\newcommand is often better than \def, as it will issue a warning if the command is already defined; if you know it's defined and want to overwrite it, you can use \renewcommand with exactly the same syntax.

Arun Debray
  • 7,126
  • 2
  • 30
  • 54
  • That's what I said. But I wouldn't post it as an answer without knowing something about \citeasnoun as it might not be safe. Do you know where it is from? If so, can you complete the example? – cfr Nov 29 '15 at 04:35
  • 2
    @cfr, I don't know much about it. Searching around suggests that it's from the harvard package (see here for documentation), but I agree that a priori we have no idea if this is the same package OP is using. – Arun Debray Nov 29 '15 at 04:41
  • Yes it's from the harvard package that I use to get the right citation style: "Author (Year)" – cas5nq Nov 29 '15 at 19:20