I am creating a script in python that automatically creates a a pdf using LaTeX. To make the automation easier I define variables in a file called Variables.tex which I load using


This works fine usually, however now I want to create a variable with a web address inside. The file looks something like this:

\def \MOParameters{A, B, C}
\def \MOTitle{Measurements at location X}
\def \MORawDataURL{https://location/to/the/file}
\def \MOCountry{Countryname}

I then use these variables (it works fine without the variable with the web-address) like such:

Parameters: & \MOParameters{}\\
Link to:    & \href{\MORawDataURL}{raw data}\\

This however gives an error (undefined control sequence), does anybody know why?

Full document (left out comments and package loading and some simple stuff) test.tex:


     \tableofcontents %Table of contents

    \chapter{Data information}
        \section{Meta data}
            \begin{tabular}{p{4cm} p{7cm}}
                Title:              & \MOTitle{}\\
                Source:             & \MOSource{}\\
                Parameters:         & \MOParameters{}\\
                Link to:            & \href{\MORawDataURL}{raw data}\\


\def \MOParameters{A, B, C}
\def \MOTitle{Measurements at location x}
\def \MORawDataURL{https://localhost-108/subdir/Data/CT 2015.011/Pars}
\def \MOSource{Data}
  • 2
    Where is \MOParameters defined? That's the undefined macro the compilation complains about. The rest works, if it is put in a compilable document, which is your task, actually ;-)
    – user31729
    Oct 9, 2017 at 14:55
  • 4
    No, give a document, not just fragments here ...
    – user31729
    Oct 9, 2017 at 14:59
  • 2
    you should put \usepackage{hyperref} below your documentclass.
    – Marijn
    Oct 9, 2017 at 15:09
  • 1
    This is a classic example of why providing a complete minimal example (or see here) is almost always so useful. The problem would've been detected instantly.
    – jon
    Oct 9, 2017 at 15:13
  • 1
    Be aware that some input in an url (e.g. # and %) will need special care. Oct 9, 2017 at 15:20

1 Answer 1


For using \href you need to load the hyperref package.


\def \MOParameters{A, B, C}
\def \MOTitle{Measurements at location X}
\def \MORawDataURL{https://location/to/the/file}
\def \MOCountry{Countryname}

Parameters: \MOParameters{}

Link to:    \href{\MORawDataURL}{raw data}


enter image description here

  • Well done ........... spotting the error before I could :D
    – user31729
    Oct 9, 2017 at 15:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .