Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to include the source citation everytime I use an image in my thesis. I have a self-written command to ease that process (code at the end of the post):

\bild[citation]{label for refs}{file}{name of the image}{size in cm}

When I try to include citation as a \cite-command (using the harvard-package), latex throws following error:

<argument> \cite 
                 {ferstl_grundlagen_2008}
\equal #1#2#3->\TE@throw \def \@tempa {#1
                                         }\def \@tempb {#2}\noexpand \ifx \@...

\NROrg@ifthenelse ...eval \the \toks@ \TE@endeval 
                                                  }\endgroup \@gtempa \expan...

\\bild ...-0.3cm\ifthenelse {\equal {#1}{\empty }}
                                                   {\caption [{#4}]{#4}} {\c...
l.12 ...en/aufgabenstruktur}{Aufgabenstruktur}{12}

? 

The command I used was following:

\bild[\cite{ferstl_grundlagen_2008}]{aufgabenstruktur}{FeSi-Aufgaben/aufgabenstruktur}{Aufgabenstruktur}{12}

I think this is a problem of the harvard implementation of \cite, as I recently used this piece of code with the bibgerm-package, where it worked like a charm. What am I doing wrong here? Is there any easy way to fix this problem?

Thanks in advance,

Uli

EDIT: Code of the \bild-macro:

\newcommand{\bild}[5][\empty]{%
  \begin{figure}[htb]%
    \begin{center}%
      \includegraphics[width=#5cm]{images/#3}%
      \vskip -0.3cm%
    \ifthenelse{\equal{#1}{\empty}}
        {\caption[{#4}]{#4}}
            {\caption[{#4} \newline \small{\textit{Quelle: #1}}]{#4}}%
      \vskip -0,2cm%
      \label{#2}%
    \end{center}%
  \end{figure}%
}

Used packages & document class:

\documentclass[a4paper, 12pt]{article}
\usepackage{german}
\usepackage[latin1]{inputenc}
\usepackage{fancyhdr}
\usepackage[T1]{fontenc}
\usepackage{ae}
\usepackage{listings}
\usepackage{color}
\usepackage{listings}
\usepackage{harvard}
\usepackage{wrapfig}
\usepackage{helvet}
\usepackage{txfonts}
\usepackage{geometry}
\usepackage{setspace}
\usepackage{hyperref}
\usepackage{sectsty}
\usepackage{acronym}
\usepackage{eurosym}
share|improve this question
    
Welcome to TeX.SE! Please edit your question to show (at a minimum) the actual definition of the \bild macro as well as the document class and any citation-relevant packages. –  Mico Jul 31 '12 at 10:14
    
Thanks for your response. I added all of the information as i didn't really know what to leave out. Sorry. I also have to say that I used the same template when citing with bibgerm. I just added the geometry-package. –  Uli Jul 31 '12 at 10:57
    
Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. And trim down your included packages, please - or add the kitchen sink. And please include the complete error message. –  Martin Schröder Jul 31 '12 at 16:46

1 Answer 1

up vote 2 down vote accepted

(Answer updated with full MWE)

Not having access to your image files or the bib file that sets up the entry with key ferstl_grundlagen_2008, I can't be entirely sure what's going on. Here's a suggested solution:

\documentclass{article}
\usepackage{german,harvard,ifthen}
\usepackage[demo]{graphicx} % get rid of 'demo' option in real document
\usepackage{hyperref}
\newcommand{\bild}[5][\empty]{%
  \begin{figure}[htbp]%
     \centering
     \includegraphics[width=#5cm]{images/#3}%
     \caption{#4}
     \label{#2}%
     \ifthenelse{\equal{#1}{\empty}}
        {}
        {\small\emph{Quelle: #1}}
  \end{figure}%
}

\begin{document}
\bild[Ferstl (2008)]{fig:1}{FeSi-Aufgaben/aufgabenstruktur}%
   {Aufgabenstruktur}{12}
\bild{fig:2}{FeSi-Aufgaben/aufgabenstruktur}{Neue Aufgabenstruktur}{10}
\end{document}

enter image description here

Incidentally, given that you use the harvard citation management package, you should probably be using the command \citeasnoun rather than \cite in the first, optional argument of \bild.

In addition, since it appears that you use the hyperref package as well, you may want to load the natbib and har2nat packages instead of the harvard package. The reason for this recommendation is that while hyperref works sort of OK with several citation management packages, it really does work best with the natbib package. As you can probably tell from its name, the har2nat package "translates" harvard-style citation commands (such as \citeasnoun) to equivalent natbib-style citation commands. That way, you can keep using the harvard-style citation commands while getting all the benefits of the good interplay between the natbib and hyperref packages

share|improve this answer
    
Thank you for your quick answer. Unfortunately, your solution for the \bild-macro throws the same error with both the \cite- and the \citeasnoun-command. Also, usage of the both packages you suggested throws another error: Undefined control sequence (\harvardcite). There is nothing I would love more than to replace the harvard-package with any other, but my prof demands a certain citation style which forces me to use makebst. The custom bst-file produces \harvarditem-bibliographies, so I think I'm stuck with this. –  Uli Jul 31 '12 at 12:03
    
@Uli - Sorry, I should have mentioned that you will need to delete all aux files ahead of the first time you run the new setup (without harvard being loaded), in order to clear away all \harvardcite instances. I've also modified the example code to a full MWE. –  Mico Jul 31 '12 at 12:24
    
Thank you very much! Works great! EDIT: what I recognized: I copied the source of the \bild-macro from my previous document and forgot to use the ifthen-package. This also most certainly was a problem. –  Uli Jul 31 '12 at 12:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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