4

You've saved my life in some occasions, I am writing my master thesis and as I am working with MATLAB, I found a very useful MATLAB function which "translate" MATLAB images to TeX tikzpicture.

I decided to put the images in some folders and to call them with a "input" command, so i make everything like this:

\begin{figure}[H]
\centering  
    \input{./images/cap3/expmcwe/imax150t100.tex}
\caption{Results at time $t=100$ with $i_{max}=150$}
    \label{fig:imax150t100exp}
\end{figure}

and everything worked fine.

Then i tried to recall the images with the \vref command, recalling the labels i wrote (i made copy+paste to be sure!) and they doesn't recall anything. They write something like:"as we can see in figure ?? on page 79"; the page is correct but there is no figure number!

Just to be clear:

  • I have uploaded all the necessary packages (I also put hyperref before varioref)
  • I use TeXShop on Mac
  • I have read all the manuals of the packages and found nothing
  • I have to give my thesis to my tutor on thursday :)

I hope some of you have a piece of advice for me!

Thank you in advice to all of you.

[EDIT] I add some more informations:

I am writing in the {book} environment, and it's a bit complicated to write here how my file is because I have one main file with the heading of my thesis recalling all the chapters. However I'll put here the code of the document which stays after the \usepackage (which are something like 40, so i don't know if it is useful to put them all...

\begin{document}

\title{---}
\providecommand{\autore}{}
\providecommand{\coautore}{}
\providecommand{\cocoautore}{}                       
\providecommand{\principaladviser}{---}  
\providecommand{\corelatore}{}
\providecommand{\secondadviser}{}
\providecommand{\annoacc}{}
\providecommand{\corso}{\uppercase{---}}
\providecommand{\nomecorso}{}
\titlep
\thispagestyle{empty}

\cleardoublepage

\thispagestyle{empty} % citazione
    \begin{flushright}
    \vspace*{4 cm}
    \textit{---}\\
    \end{flushright}

 \newpage
\thispagestyle{empty}

\cleardoublepage

\thispagestyle{empty} % dedica
\begin{flushright}
%   \vspace*{4 cm}
%   \textit{ \\
%   }\\
%   []\\

%   \vspace{2cm}
%   \textit{}\\
%   ()
    \end{flushright}

     \newpage
\thispagestyle{empty}

    %\maketitle
    \cleardoublepage
    \input{abstract}
    \newpage
    \thispagestyle{empty}

\frontmatter    
    \newpage
    \tableofcontents    

    \listoffigures

    \listoftables

    \lstlistoflistings

    \newpage
    \printnomenclature

\mainmatter


\pagestyle{fancy}
        %\fancyhead[LO]{} 
        %\fancyhead[RE]{}
        \fancyhead{}
        \fancyhead[RO,LE]{\slshape \leftmark}
        \fancyfoot{}
        \fancyfoot[RO,LE]{\thepage}
 \fancypagestyle{plain}{%
 \fancyfoot{}
 \fancyfoot[RO,LE]{\thepage}}

    \input{introd}

    \input{cap1}
        \input{cap2}
        \input{cap3}
%    \input{cap4}
%    \input{cap5}
%    \input{cap6}

%   \input{conclusion}  

    \cleardoublepage 
    %\phantomsection
    \addcontentsline{toc}{chapter}{\bibname}
    \bibliographystyle{plainnat}
    \bibliography{bibliography}

    \cleardoublepage
    \input{acknowledgement}
    \newpage
    \thispagestyle{empty}

\end{document}
  • Welcome to TeX.SX. Note that you don't have to sign with your name since it automatically appears in the lower right corner of your post. – Claudio Fiandrino Oct 18 '13 at 17:20
  • Welcome to TeX.SX! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – clemens Oct 18 '13 at 17:20
  • 1
    You should load hyperref after varioref. If that still doesn't work, try (surprising as this may sound at first) loading the cleveref package as well (after hyperref). See also tex.stackexchange.com/q/51636/5001. – Mico Oct 18 '13 at 18:06
  • Thank you Mico, your advice worked for me, I am so relieved :) – brodegon Oct 18 '13 at 18:14
  • 1
    pay attention anyway, because cleveref changes the reference names; for example one has to set the {lstlisting} name (\crefname{lstlisting}{code}{codes} or \crefname{lstlisting}{script}{scripts} and \Crefname{lstlisting}{code}{codes}) but also it repeats objects name: "see for example table \vref{tab:first}" gives as output:"see for example table table first" – brodegon Oct 21 '13 at 13:21
6

The key piece of information, I believe, is that you load the hyperref package before the varioref package.

A solution to the problems you report consists of (a) loading varioref before hyperref and (b) loading cleveref as well, after hyperref. The reason this works is that when cleveref is loaded, it checks if varioref is loaded and, if the answer is yes, modifies some of varioref's internals in order to improve interoperability with cleveref. (Of course, for this to work cleveref must be loaded after varioref...) In the process, varioref also becomes more compatible -- I'm not sure if it's OK to say fully compatible -- with hyperref. For more information on this matter, see the posting Lost labels using intertext with varioref and hyperref.

In short, if you load the packages varioref, hyperref, and cleveref in this order, you should be able to use \vref without further problems.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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