I have data sets with tables like this one:

@ DATE %s 16/06/16
@ TIME %s 17-01-45
XY.1 10
XY.2 20
XY.3 25

Plotting and reading the table in general works with

\addplot[] table[comment chars={@}, x expr=\coordindex+1, y = POS] {Data.txt};

But can I use the time and date from the comment lines in the title or label of the plot?

Thanks for your help!

  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Seamus Jul 5 '16 at 13:51

The command \date is defined to set the internal variable \@date to whatever you type. e.g \date{2016-07-05} sets the variable to 2016-07-05. Variables contain a @ so you can easily spot them. Quite simple up to here.

If you want to print the value of that variable, you cannot simply type \@date, this will produce an error as the @ is not allowed in "standard" .tex-files in order to keep the user from changing internal settings which could cause a lot of trouble. Therefore you need to type \makeatletter \@date \makeatother . With \makeatletter you tell LaTeX that you are willing to deal with variables and \makeatother then disables that. The following MWE shows this.

bla & \makeatletter \@date \makeatother
  • 1
    Hi Enno, thanks for your answer. What I actually try to do is to read the date and time (can be any other string) from the comment lines in the table (the first two lines in the example table marked with @). They are references for my measurements. Do you know how to do that? I'm really happy for any advice. Cheers, Jay – Jay Jul 5 '16 at 15:10

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.