Discussion:
have \autoref show the parameter of the referenced environment
(too old to reply)
CQ
2010-06-02 10:31:46 UTC
Permalink
Hi everybody,

I am using \autoref in my scientific documents. It works fine.
However, I would be glad if \autoref would provide the following
feature: suppose you define a theorem

[...]
\begin{theorem}{theorem caption}\label{thm:test}
something
\end{theorem}
[...]

In my text I then reference the theorem using

[...]
\autoref{thm:test}
[...]

This prints out

[...]
Theorem 1
[...]

which is very nice. But what I would really need now is a print out
like this

[...]
Theorem 1 (theorem caption)
[...]

So that the caption (or first parameter so to speak) of the theorem
definition is shown as well. Does anyone know of such a feature or is
it possible to implement it? I am not too much into LaTeX, so I have
no idea how to do this.

Thanks in advance!

CQ.
Claas Hemig
2010-06-02 11:31:14 UTC
Permalink
Hi,
Post by CQ
which is very nice. But what I would really need now is a print out
like this
[...]
Theorem 1 (theorem caption)
[...]
use nameref:

\documentclass{minimal}
\usepackage{amsmath,hyperref}
\newcommand{\myref}[1]{\autoref{#1}~(\nameref{#1})}
\begin{document}
\newtheorem{theorem}{Theorem}
\begin{theorem}[My Theorem]\label{theo:My}0=0
\end{theorem}
\myref{theo:My}
\end{document}

HTH, Claas
CQ
2010-06-02 12:59:30 UTC
Permalink
Post by Claas Hemig
Hi,
Post by CQ
which is very nice. But what I would really need now is a print out
like this
[...]
Theorem 1 (theorem caption)
[...]
\documentclass{minimal}
\usepackage{amsmath,hyperref}
\newcommand{\myref}[1]{\autoref{#1}~(\nameref{#1})}
\begin{document}
\newtheorem{theorem}{Theorem}
\begin{theorem}[My Theorem]\label{theo:My}0=0
\end{theorem}
\myref{theo:My}
\end{document}
HTH, Claas
This works somehow fine. There is one problem: \nameref{} references
the wrong theorem. Referencing theo:My, for instance, brings up the
name of some other theorem in my document (which contains quite a
bunch of theorems).

CQ.
Claas Hemig
2010-06-02 14:39:28 UTC
Permalink
Hi,
Post by CQ
This works somehow fine. There is one problem: \nameref{} references
the wrong theorem. Referencing theo:My, for instance, brings up the
name of some other theorem in my document (which contains quite a
bunch of theorems).
I don't think that nameref does a wrong referencing itself, there must
be a side effect of another package you use. ntheorem perhaps?
Please make a minimal example that shows your problem. Just guessing
around is not my way of problem solving...

Kind regards, Claas
Ulrich M. Schwarz
2010-06-03 04:23:42 UTC
Permalink
Post by CQ
Post by Claas Hemig
Hi,
Post by CQ
which is very nice. But what I would really need now is a print out
like this
[...]
Theorem 1 (theorem caption)
[...]
\documentclass{minimal}
\usepackage{amsmath,hyperref}
\newcommand{\myref}[1]{\autoref{#1}~(\nameref{#1})}
\begin{document}
\newtheorem{theorem}{Theorem}
\begin{theorem}[My Theorem]\label{theo:My}0=0
\end{theorem}
\myref{theo:My}
\end{document}
HTH, Claas
This works somehow fine. There is one problem: \nameref{} references
the wrong theorem. Referencing theo:My, for instance, brings up the
name of some other theorem in my document (which contains quite a
bunch of theorems).
It's possible that nameref gets confused when several theorem types share
the same numbering: then, the counter name has nothing to do with the
environment name. You might try adding \usepackage{thmtools}, recent
versions
have explicit code for nameref, maybe it'll help.
Due to the TeXLive freeze, that might mean getting it from
http://absatzen.de.

HTH
Ulrich
CQ
2010-06-04 10:36:27 UTC
Permalink
Post by Ulrich M. Schwarz
Post by CQ
Post by Claas Hemig
Hi,
Post by CQ
which is very nice. But what I would really need now is a print out
like this
[...]
Theorem 1 (theorem caption)
[...]
\documentclass{minimal}
\usepackage{amsmath,hyperref}
\newcommand{\myref}[1]{\autoref{#1}~(\nameref{#1})}
\begin{document}
\newtheorem{theorem}{Theorem}
\begin{theorem}[My Theorem]\label{theo:My}0=0
\end{theorem}
\myref{theo:My}
\end{document}
HTH, Claas
This works somehow fine. There is one problem: \nameref{} references
the wrong theorem. Referencing theo:My, for instance, brings up the
name of some other theorem in my document (which contains quite a
bunch of theorems).
It's possible that nameref gets confused when several theorem types share
the same numbering: then, the counter name has nothing to do with the
environment name.  You might try adding \usepackage{thmtools}, recent  
versions
have explicit code for nameref, maybe it'll help.
Due to the TeXLive freeze, that might mean getting it from  http://absatzen.de.
HTH
  Ulrich
Hi,

it took me some time to come up with a rather small example. But here
it is.

\documentclass{scrbook}

\usepackage{classicthesis-ldpkg}
\usepackage{thm-autoref}
\usepackage{amsmath, amsthm}
\usepackage{thmtools}

\newtheorem{definition}{Definition}[section]
\newcommand{\myref}[1]{\autoref{#1}~(\nameref{#1})}

\begin{document}

\chapter{Chapter 1}
\section{Section 1}
\subsection{Subsection 1}

\begin{definition}{bla bla blub}\label{def1}%
bla bla bla
\end{definition}

\myref{def1}

\end{document}


It seems that nameref uses the caption of that particular section
which carries the same number as the definition/theorem carries that
is referenced. In one of my last posts I confused that because in my
document some sections and definitions carry the same captions ;-).

Thanks a lot again for your help!

CQ.
Ulrich M. Schwarz
2010-06-04 15:27:33 UTC
Permalink
Post by CQ
Hi,
it took me some time to come up with a rather small example. But here
it is.
\documentclass{scrbook}
\usepackage{classicthesis-ldpkg}
\usepackage{thm-autoref}
\usepackage{amsmath, amsthm}
\usepackage{thmtools}
\newtheorem{definition}{Definition}[section]
\newcommand{\myref}[1]{\autoref{#1}~(\nameref{#1})}
\begin{document}
\chapter{Chapter 1}
\section{Section 1}
\subsection{Subsection 1}
\begin{definition}{bla bla blub}\label{def1}%
The optional argument should go in [ ], shouldn't it?
But you seem to have uncovered a regression bug: a missing autorefname for
definition
shouldn't occur just because you load thm-autoref separately. I'll take a
look.

Ulrich
Ulrich M. Schwarz
2010-06-04 15:33:19 UTC
Permalink
Post by Ulrich M. Schwarz
Post by CQ
Hi,
it took me some time to come up with a rather small example. But here
it is.
\documentclass{scrbook}
\usepackage{classicthesis-ldpkg}
\usepackage{thm-autoref}
\usepackage{amsmath, amsthm}
\usepackage{thmtools}
\newtheorem{definition}{Definition}[section]
\newcommand{\myref}[1]{\autoref{#1}~(\nameref{#1})}
\begin{document}
\chapter{Chapter 1}
\section{Section 1}
\subsection{Subsection 1}
\begin{definition}{bla bla blub}\label{def1}%
The optional argument should go in [ ], shouldn't it?
But you seem to have uncovered a regression bug: a missing autorefname
for definition
shouldn't occur just because you load thm-autoref separately. I'll take
a look.
Argh. Brainfry: just remove the \usepackage{thm-autoref}. It's not
amending the
right \newtheorem, since you load amsthm only afterwards, but in your case,
thmtools won't load it a second time since it's already loaded.
(I guess thm-* could prevent amsthm and ntheorem to be loaded after them,
but that
would be rude.)

Ulrich
CQ
2010-06-04 15:49:35 UTC
Permalink
Post by Ulrich M. Schwarz
Post by CQ
Hi,
it took me some time to come up with a rather small example. But here
it is.
\documentclass{scrbook}
\usepackage{classicthesis-ldpkg}
\usepackage{thm-autoref}
\usepackage{amsmath, amsthm}
\usepackage{thmtools}
\newtheorem{definition}{Definition}[section]
\newcommand{\myref}[1]{\autoref{#1}~(\nameref{#1})}
\begin{document}
\chapter{Chapter 1}
\section{Section 1}
\subsection{Subsection 1}
\begin{definition}{bla bla blub}\label{def1}%
The optional argument should go in [ ], shouldn't it?
But you seem to have uncovered a regression bug: a missing autorefname  
for definition
shouldn't occur just because you load thm-autoref separately. I'll take  
a look.
Argh. Brainfry: just remove the \usepackage{thm-autoref}. It's not  
amending the
right \newtheorem, since you load amsthm only afterwards, but in your case,
thmtools won't load it a second time since it's already loaded.
(I guess thm-* could prevent amsthm and ntheorem to be loaded after them,  
but that
would be rude.)
Ulrich
I have removed \usepackage{thm-autoref}. But then, I have to remove
thmtools as well. Otherwise, I get an error "Command \theoremstyle
already defined...". But removing both packages does not make nameref
work correctly as well - I get the same result as posted above. I have
no clue about what is going on here....

CQ.
Ulrich M. Schwarz
2010-06-04 16:09:17 UTC
Permalink
Post by CQ
I have removed \usepackage{thm-autoref}. But then, I have to remove
thmtools as well. Otherwise, I get an error "Command \theoremstyle
already defined...". But removing both packages does not make nameref
work correctly as well - I get the same result as posted above. I have
no clue about what is going on here....
Please try updating to a more recent version of thmtools. I was unable to
reproduce that problem with either v17 or v29.

Ulrich
CQ
2010-06-06 10:28:51 UTC
Permalink
Post by Ulrich M. Schwarz
Post by CQ
I have removed \usepackage{thm-autoref}. But then, I have to remove
thmtools as well. Otherwise, I get an error "Command \theoremstyle
already defined...". But removing both packages does not make nameref
work correctly as well - I get the same result as posted above. I have
no clue about what is going on here....
Please try updating to a more recent version of thmtools. I was unable to
reproduce that problem with either v17 or v29.
Ulrich
I work on Mac OS X (Snow Leopard) and I have no clue on how to install
the thmtools package from your homepage. Could you help me on that as
well. I have downloaded the zip file and unpacked it. But where shall
I put the files now?

Thanks a lot again,

CQ.
Alan Munn
2010-06-06 14:16:13 UTC
Permalink
In article
Post by CQ
Post by Ulrich M. Schwarz
Post by CQ
I have removed \usepackage{thm-autoref}. But then, I have to remove
thmtools as well. Otherwise, I get an error "Command \theoremstyle
already defined...". But removing both packages does not make nameref
work correctly as well - I get the same result as posted above. I have
no clue about what is going on here....
Please try updating to a more recent version of thmtools. I was unable to
reproduce that problem with either v17 or v29.
Ulrich
I work on Mac OS X (Snow Leopard) and I have no clue on how to install
the thmtools package from your homepage. Could you help me on that as
well. I have downloaded the zip file and unpacked it. But where shall
I put the files now?
Thanks a lot again,
CQ.
Unless the version on the homepage is different from the one on CTAN,
you should probably update using the TeXLive Utility instead of
installing it manually. Otherwise you'll forget you have a local
version and will miss any future updates.

But if you do need to install things manually, once you have unpacked
the files they do into your ~/Library/texmf folder. (I.e. your home
Library/texmf folder.)

Latex style files (or a folder that contains them) go in
~/Library/texmf/tex/latex
Documentation goes ~/Library/texmf/doc
Bst files go in ~/Library/texmf/bibtex/bst

etc.

Alan
Ulrich M. Schwarz
2010-06-06 14:50:14 UTC
Permalink
Post by Alan Munn
Unless the version on the homepage is different from the one on CTAN,
you should probably update using the TeXLive Utility instead of
installing it manually.
Since updates are frozen in anticipation of TL2010, it is well possible
that
the version you can get through tlmgr is not even the most recent one on
CTAN,
much less the most recent one. (I don't push up every small change and fix,
Jim has enough work to do.) Unfortunately, my understanding of the tlmgr
mechanism is that -- unlike almost every other package manager -- you
cannot
throw it a local file to install, so I cannot put something on the web so
that
tlmgr install --local mypackage.tar.gz or whatever will install it.
Post by Alan Munn
Otherwise you'll forget you have a local
version and will miss any future updates.
Ah, he won't miss them, i.e. tlmgr will update them, but they'll be
overridden
because the local file takes precedence.

Finding files that exist in more than one texmf tree and comparing, for
example,
their file dates, is an exercise in the "find your way around the API"
difficulty,[1]
and I'm sure somebody will point out how it can be done in one line in
Haskell.
It might be slight overkill for every update run, but "shall I check
LOCALTEXMF for
outdated versions of packages I just installed" is something that would
make sense
for the TL installer.

Ulrich

[1] I have a bash take on it around somewhere
Alan Munn
2010-06-06 15:19:57 UTC
Permalink
Post by Ulrich M. Schwarz
Post by Alan Munn
Unless the version on the homepage is different from the one on CTAN,
you should probably update using the TeXLive Utility instead of
installing it manually.
Since updates are frozen in anticipation of TL2010, it is well
possible that the version you can get through tlmgr is not even the
most recent one on CTAN, much less the most recent one. (I don't
push up every small change and fix, Jim has enough work to do.)
Unfortunately, my understanding of the tlmgr mechanism is that --
unlike almost every other package manager -- you cannot throw it a
local file to install, so I cannot put something on the web so that
tlmgr install --local mypackage.tar.gz or whatever will install it.
True enough. It depends on how recently the relevant update that is
causing his problem is. This is an unfortunate time of the release
cycle to be a new user.
Post by Ulrich M. Schwarz
Post by Alan Munn
Otherwise you'll forget you have a local
version and will miss any future updates.
Ah, he won't miss them, i.e. tlmgr will update them, but they'll be
overridden because the local file takes precedence.
Which effectively means he'll miss them, given that he doesn't yet know
even where to put things.

Seeing as the OP seems somewhat new to everything, I was trying to
suggest a solution that wouldn't come back and bite him later. Having
local versions of a package that is normally part of TeXLive is never a
great idea, unless you are really aware of what you have.
Post by Ulrich M. Schwarz
Finding files that exist in more than one texmf tree and comparing,
for example, their file dates, is an exercise in the "find your way
around the API" difficulty,[1] and I'm sure somebody will point out
how it can be done in one line in Haskell. It might be slight
overkill for every update run, but "shall I check LOCALTEXMF for
outdated versions of packages I just installed" is something that
would make sense for the TL installer.
Yes and no, depending on what the installer does with the information.
Informing the user that they have outdated local versions would
definitely be helpful. Anything more (such as deleting them) would not
be a good idea. Sometimes you need an older version of a package because
some other package that depends on it hasn't been updated. A striking
example of this would be biblatex, which when v0.9 came out, broke a lot
of extensions by others that had worked with v0.8, so it was necessary
to have a local older version for a while.

Alan
Ulrich M. Schwarz
2010-06-06 14:59:31 UTC
Permalink
Post by CQ
Post by Ulrich M. Schwarz
Post by CQ
I have removed \usepackage{thm-autoref}. But then, I have to remove
thmtools as well. Otherwise, I get an error "Command \theoremstyle
already defined...". But removing both packages does not make nameref
work correctly as well - I get the same result as posted above. I have
no clue about what is going on here....
Please try updating to a more recent version of thmtools. I was unable to
reproduce that problem with either v17 or v29.
Ulrich
I work on Mac OS X (Snow Leopard) and I have no clue on how to install
the thmtools package from your homepage. Could you help me on that as
well. I have downloaded the zip file and unpacked it. But where shall
I put the files now?
I hope you mean tar.gz, because the zip is for historical reasons more
than anything else.
Assuming you're in a shell (command line) in the directory which contains
your
downloaded thmtools-v29.tar.gz, enter:
tar xfzv thmtools-v29.tar.gz
[you'll see the archive being uncompressed]
cd thmtools-v29
tex thmtools.ins
mkdir -p $(kpsexpand \$TEXMFHOME)/tex/latex/thmtools
cp *.sty $(kpsexpand \$TEXMFHOME)/tex/latex/thmtools
mkdir -p $(kpsexpand \$TEXMFHOME)/doc/latex/thmtools
cp *.pdf $(kpsexpand \$TEXMFHOME)/tex/latex/thmtools

I see I better resume creating both the zip and the tar.gz source tree.

HTH
Ulrich
CQ
2010-06-07 10:53:49 UTC
Permalink
Post by CQ
Post by CQ
I have removed \usepackage{thm-autoref}. But then, I have to remove
thmtools as well. Otherwise, I get an error "Command \theoremstyle
already defined...". But removing both packages does not make nameref
work correctly as well - I get the same result as posted above. I have
no clue about what is going on here....
Please try updating to a more recent version of thmtools. I was unable  
to
reproduce that problem with either v17 or v29.
Ulrich
I work on Mac OS X (Snow Leopard) and I have no clue on how to install
the thmtools package from your homepage. Could you help me on that as
well. I have downloaded the zip file and unpacked it. But where shall
I put the files now?
I hope you mean tar.gz, because the zip is for historical reasons more  
than anything else.
Assuming you're in a shell (command line) in the directory which contains  
your
tar xfzv thmtools-v29.tar.gz
[you'll see the archive being uncompressed]
cd thmtools-v29
tex thmtools.ins
mkdir -p $(kpsexpand \$TEXMFHOME)/tex/latex/thmtools
cp *.sty $(kpsexpand \$TEXMFHOME)/tex/latex/thmtools
mkdir -p $(kpsexpand \$TEXMFHOME)/doc/latex/thmtools
cp *.pdf $(kpsexpand \$TEXMFHOME)/tex/latex/thmtools
I see I better resume creating both the zip and the tar.gz source tree.
HTH
  Ulrich
I did mean the tar.gz. Sorry, I confused that. Well, I did as you
suggested. But still, nameref does not want to reference the right
thing. It keeps showing chapter/section/subsection names. For me it
seems that it shows the name of the chapter/section/subsection that
the referenced definition, for instance, is associated to.

CQ

Loading...