Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

LaTeX and references

132 views
Skip to first unread message

Mikael Kujanpää

unread,
May 31, 2005, 8:15:16 PM5/31/05
to
I'm working with my thesis. I have made my own bst-file with custombib, and
it is working pretty well. However, there is a problem. At text, my
bibtex-style produces references like this:

Text (Reference 2005).

Unfortunately, in some cases references should be like this:

Text. Text. Text. (Reference 2005.)

Notice the period inside parenthesis.

At Finnish tex-newsgroup I was adviced to use natbib. However, that cannot
be done because I need authordate1-4.sty, and these two conflicts.

I tried to study how authordate1-4.sty builds references, and I found these
lines:

\def\@cite#1#2{(#1\if@tempswa , #2\fi)}
...
\let\@internalcite\cite
\def\cite{\def\citename##1{##1}\@internalcite}

I changed the first line to be: "\def\@cite#1#2{(#1\if@tempswa , #2\fi.)}".
As I thought, all my references changed to "(Reference 2005.)". Great, I
thought I was getting clue. But, as I tried to produce my own \citelp
-command, at least this wasn't working:


\def\@citelp#1#2{(#1\if@tempswa , #2\fi.)}
...
\let\@internalcitelp\citelp
\def\citelp{\def\citename##1{##1}\@internalcitelp}

When I tried to compile tex-source, I was getting error complaining citelp
isn't defined.

How I can get this to work?

Of cource, optimal solution would be that LaTeX notices by itself, when it
should use form "(Reference 2005)" and when "(Reference 2005.)". The
pseudo-rule for this could be "when there is period-space before
\cite{}-command, use form (surname year.), otherwise use form (surname
year)". But where this should be placed, and how it should be written?

I'm afraid optimal solution is too hard to get work, so at least different
command for different form is acceptable solution. The last alternative is
making references "by hand" (ie. to write straight to .tex-file
(Reference...)).

I'm sorry if my english isn't understable enought, I'm not native English
speaker. But hopefully somebody can help me.

--
Mikki

Ulrike Fischer

unread,
Jun 1, 2005, 3:22:57 AM6/1/05
to
Mikael Kujanpää <mikael.kuj...@nic.fi> schrieb:


> I tried to study how authordate1-4.sty builds references, and I found
> these lines:
>
> \def\@cite#1#2{(#1\if@tempswa , #2\fi)}
> ...
> \let\@internalcite\cite
> \def\cite{\def\citename##1{##1}\@internalcite}

The \let stores the old definition of \cite and then the \def define
\cite by using this old value. So the old value needs to be defined
before.


>
> I changed the first line to be: "\def\@cite#1#2{(#1\if@tempswa ,
> #2\fi.)}". As I thought, all my references changed to "(Reference
> 2005.)". Great, I thought I was getting clue. But, as I tried to
> produce my own \citelp -command, at least this wasn't working:
>
>
> \def\@citelp#1#2{(#1\if@tempswa , #2\fi.)}
> ...
> \let\@internalcitelp\citelp
> \def\citelp{\def\citename##1{##1}\@internalcitelp}
>
> When I tried to compile tex-source, I was getting error complaining
> citelp isn't defined.
>
> How I can get this to work?

Define \citelp (which I guess should internally use \@citelp). Look how
\cite is defined in your class/package.

You can use

http://www.tex.ac.uk/cgi-bin/texfaq2html?label=ltxcmds

to find out how \cite is defined before the redefinition.

--
Ulrike Fischer
e-mail: zusätzlich meinen Vornamen vor dem @ einfügen.
e-mail: add my first name between the news and the @.

Mikael Kujanpaa

unread,
Jun 1, 2005, 6:55:59 AM6/1/05
to
Ulrike Fischer wrote:

> The \let stores the old definition of \cite and then the \def define
> \cite by using this old value. So the old value needs to be defined
> before.

Okay, thanks for information. This explains why my first version didn't
work.

> Define \citelp (which I guess should internally use \@citelp). Look how
> \cite is defined in your class/package.

I added command

*\show\cite

right after \begin{document} at my tex-source. That gave me:

> \cite=macro:
->\def \citename ##1{##1}\@internalcite .
l.29 *\show\cite

This wasn't very helpful for me, but I tried add to authordate1-4.sty the
following modifications:

\def\@citelp#1{\def \citename ##1{##1}\@internalcite}

\def\@cite#1#2{(#1\if@tempswa , #2\fi)}

\def\@citelp#1#2{(#1\if@tempswa , #2\fi.)}

...

\let\@internalcite\cite
\let\@internalcitelp\citelp


\def\cite{\def\citename##1{##1}\@internalcite}

\def\citelp{\def\citename##1{##1}\@internalcitelp}

But when there is command \citelp at my actual tex file, LaTeX complains
about it:

! Undefined control sequence.
\citelp ->\def \citename ##1{##1}\@internalcitelp

l.15 \citelp
{oss_virallinen}

--
Mikki

Ulrike Fischer

unread,
Jun 1, 2005, 9:39:31 AM6/1/05
to
Mikael Kujanpaa <mikael.kuj...@nic.fi> schrieb:

> Ulrike Fischer wrote:
>
>> The \let stores the old definition of \cite and then the \def define
>> \cite by using this old value. So the old value needs to be defined
>> before.
>
> Okay, thanks for information. This explains why my first version didn't
> work.
>
>> Define \citelp (which I guess should internally use \@citelp). Look how
>> \cite is defined in your class/package.
>
> I added command
>
> *\show\cite
>
> right after \begin{document} at my tex-source. That gave me:

Put the command in the _sty_ directly before the \let-command. Or put
in your source \makeatletter\show\@internalcite\makeatother which
should work too as \@internalcite got the old definition of \cite.

>
>> \cite=macro:
> ->\def \citename ##1{##1}\@internalcite .
> l.29 *\show\cite
>
> This wasn't very helpful for me,

Yes, at begin{document} you simply get the _new_ definition of \cite
which you know already.

> but I tried add to authordate1-4.sty the
> following modifications:
>
> \def\@citelp#1{\def \citename ##1{##1}\@internalcite}
>
> \def\@cite#1#2{(#1\if@tempswa , #2\fi)}
> \def\@citelp#1#2{(#1\if@tempswa , #2\fi.)}
>
> ...
>
> \let\@internalcite\cite
> \let\@internalcitelp\citelp

\citelp isn't defined yet so \@internalcitelp=undefined

> \def\cite{\def\citename##1{##1}\@internalcite}
> \def\citelp{\def\citename##1{##1}\@internalcitelp}
>
> But when there is command \citelp at my actual tex file, LaTeX complains
> about it:
>
> ! Undefined control sequence.
> \citelp ->\def \citename ##1{##1}\@internalcitelp

As I said: you need to define \citelp _before_ the \let command.

Mikael Kujanpaa

unread,
Jun 1, 2005, 3:01:07 PM6/1/05
to
Ulrike Fischer wrote:

>> I added command
>>
>> *\show\cite
>>
>> right after \begin{document} at my tex-source. That gave me:
>
> Put the command in the _sty_ directly before the \let-command.

This doesn't work:

(./authordate1-4.sty

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.82 *
\show\cite

> Or put in your source \makeatletter\show\@internalcite\makeatother which
> should work too as \@internalcite got the old definition of \cite.

But this -- right after \begin{document} -- worked as should:

(/usr/share/texmf/tex/latex/psnfss/t1ptm.fd)
> \@internalcite=macro:
->\protect \cite .
l.31 \makeatletter\show\@internalcite
\makeatother

That doesn't tell very much, but luckily faq already points to right
direction. I added these lines to my tex-source:

\begin{document}
*\def\pshow#1{{\let\protect\show #1}}

\makeatletter\pshow\@internalcite\makeatother

And I believe this eventually gives me the definition of original \cite:

(/usr/share/texmf/tex/latex/psnfss/t1ptm.fd)
> \cite =\long macro:
->\@ifnextchar [{\@tempswatrue \@citex }{\@tempswafalse \@citex []}.
\@internalcite ->\protect \cite

l.31 \makeatletter\pshow\@internalcite
\makeatother

Okay. I modified authordate1-4.sty:

% these two lines are together:
\def\@citelp#1#2{\@ifnextchar [{\@tempswatrue \@citex }{\@tempswafalse
\@citex []}}

\def\@cite#1#2{(#1\if@tempswa , #2\fi)}
\def\@citelp#1#2{(#1\if@tempswa , #2\fi.)}

\def\@biblabel#1{}


...
\let\@internalcite\cite
\let\@internalcitelp\citelp

\def\cite{\def\citename##1{##1}\@internalcite}


\def\citelp{\def\citename##1{##1}\@internalcitelp}

I also added to tex-source other command that tells me definition of command
\internalcitelp. If I have understood correctly, it should be same as
\internalcite

When I try to compile whole thing, it all crashes to this:

! Undefined control sequence.
<argument> \@internalcitelp

l.32 \makeatletter\pshow\@internalcitelp
\makeatother

I also tried at authordate1-4.sty this form of definition of \citelp
(removed @-character at the beginning of line):

\def\citelp#1#2{\@ifnextchar [{\@tempswatrue \@citex }{\@tempswafalse
\@citex []}}

This actually gave me something:

! Argument of \@internalcitelp has an extra }.
<inserted text>
\par
l.32 \makeatletter\pshow\@internalcitelp
\makeatother

But I don't get where I do have extra }.

However, what confuses both me and Emacs, is that LaTeX tell original \cite
command to be "\@ifnextchar [{\@tempswatrue \@citex }{\@tempswafalse
\@citex []}."

Is the last period part of definition? And there is one [ character that
doesn't had the ending ] pair. Is this correct? At least Emacs doesn't like
mismatched parenthesis.

> \citelp isn't defined yet so \@internalcitelp=undefined

Just to be sure: am I trying to define \citelp correctly, ie. by using
\def... -command?

And what's the difference between \def\@cite... and \def\cite... ?

As you can see, I'm not very familiar with this level of LaTeX. Anyway, it
seems this is getting to work nearly, so I would like to get this to do
what I wanted. But I don't have enought skills to do it by myself, so your
help (or other's, if they have something to say) is really appreciated.

--
Mikki

Ulrike Fischer

unread,
Jun 2, 2005, 5:45:16 AM6/2/05
to
Mikael Kujanpaa <mikael.kuj...@nic.fi> schrieb:

> Ulrike Fischer wrote:
>
>>> I added command
>>>
>>> *\show\cite
>>>
>>> right after \begin{document} at my tex-source. That gave me:
>>
>> Put the command in the _sty_ directly before the \let-command.
>
> This doesn't work:
>
> (./authordate1-4.sty
>
> ! LaTeX Error: Missing \begin{document}.

Look try to think a bit. I said put the command in the sty, I didn't
say "and then try to run the sty". Simply run your normal source with
the changed sty (to make sure you don't loose something you should give
the changed sty another name)


> That doesn't tell very much, but luckily faq already points to right
> direction. I added these lines to my tex-source:
>
> \begin{document}
> *\def\pshow#1{{\let\protect\show #1}}
>
> \makeatletter\pshow\@internalcite\makeatother
>
> And I believe this eventually gives me the definition of original
> \cite:
>
> (/usr/share/texmf/tex/latex/psnfss/t1ptm.fd)
>> \cite =\long macro:
> ->\@ifnextchar [{\@tempswatrue \@citex }{\@tempswafalse \@citex []}.
> \@internalcite ->\protect \cite
>
> l.31 \makeatletter\pshow\@internalcite
> \makeatother

[snip]

>
> However, what confuses both me and Emacs, is that LaTeX tell original
> \cite command to be "\@ifnextchar [{\@tempswatrue \@citex
> }{\@tempswafalse \@citex []}."
>
> Is the last period part of definition?

No.


> And there is one [ character
> that doesn't had the ending ] pair. Is this correct? At least Emacs
> doesn't like mismatched parenthesis.

You have an if-then-else here: if next char is [ do.....

(This is for the optional argument of \cite).

> And what's the difference between \def\@cite... and \def\cite... ?

They are two different commands. Like \acite and \cite would be
different commands. @ is a normal letter in styles. The @ is used to
prevent normal user to overwrite internal commands.

> As you can see, I'm not very familiar with this level of LaTeX.
> Anyway, it seems this is getting to work nearly, so I would like to
> get this to do what I wanted. But I don't have enought skills to do it
> by myself, so your help (or other's, if they have something to say) is
> really appreciated.

Go back throught your styles and class and perhaps latex.ltx and find
out where \cite is defined. Copy this definition and change \cite to
\citelp. Then look at each command _in_ this definition and try to find
out if you need to change this too. It isn't really difficult to guess
that e.g. \@tempswatrue probably shouldn't be change while \@citex
needs perhaps an adaptation.

You can put your new commands and definitions in the preamble of your
document -- between \makeatletter ... \makeatother, which make @ (at) a
letter like in a style.

As long as you don't change the original files (or only temporaly for a
test) nothing can explode.

Mikael Kujanpaa

unread,
Jun 2, 2005, 8:14:14 AM6/2/05
to
Ulrike Fischer wrote:

> Look try to think a bit.

I try, but most of time it hurts too much :).

> Simply run your normal source with the changed sty

Naturally I ran normal source. But there were extra * character just before
\show (which I thought to be part of command), and that made LaTeX to
complain about that. At least the error message were quite misleading.

>> And there is one [ character that doesn't had the ending ] pair. Is this
>> correct? At least Emacs doesn't like mismatched parenthesis.
>
> You have an if-then-else here: if next char is [ do.....

I was suspecting that, thanks for confirmation.

>> And what's the difference between \def\@cite... and \def\cite... ?
>
> They are two different commands. Like \acite and \cite would be
> different commands. @ is a normal letter in styles. The @ is used to
> prevent normal user to overwrite internal commands.

Okay, this is good to know.

> Go back throught your styles and class and perhaps latex.ltx and find
> out where \cite is defined.

[clips]

I made all you said, see that this isn't working, read again and again your
introductions, iterized this procedure n times, and what! At the end, there
is period as I wanted!

So this is working now, thank you very much for your kindness. I think I
haven't ever seen so much trouble to get one tiny period where I want it to
be :). But all this were very educational, maybe next time I can do
something just by myself.

--
Mikki

0 new messages