I am writing my thesis and I want to insert month and year of some past events at lot of places! How to do that? Can anyone suggest me a simplest way to do it? I am very much beginner in LaTeX. And also please forgive me for my English.

I have these events listed in a text file. e.g. Superconductivity was discovered in April, 1991 by Heike Kamerlingh Onnes.

I am just expecting output formatted like

April, 1991

  • 1
    How are these "past events" defined? Do you just have them scribbled on a napkin, or are they in a database (like a text/CSV file)? What type of output do you expect? Please provide some examples.
    – Werner
    Nov 9, 2020 at 19:55
  • @Werner I tried to update my question. Please have a look at it. Nov 11, 2020 at 15:38

1 Answer 1


You could simply define a macro which stores the relevant data, for example, you could use \newcommand\questionDay{Monday} to store the day on which you asked this question. Then you could use \questionDay in your paragraph wherever you want to refer to this day. However, keep in mind that spaces are ignored after macro names, so if you want a space following \questionDay you could use \questionDay{} instead.

Another approach could be to store the data in some data structure and retrieve that. The following implements such a data structure that you can initialize giving a macro name and a list of key=value pairs which store properties for this macro name. When you then use the macro it'll accept one argument, being one of the properties stored earlier, and it'll typeset that property's value.

This example shows both methods:


% basic approach


% property list based approach
\msg_new:nnn { Bhargav } { already-defined }
  { #1 ~ `#2' ~ is ~ already ~ defined. }
\msg_new:nnn { Bhargav } { unknown~property }
  { The ~ property ~ `#2' ~ isn't ~ found ~ for ~ `#1'. }
\tl_new:N \l_Bhargav_tmp_tl
\NewDocumentCommand \newevent { m m }
    \prop_if_exist:cTF { c_Bhargav_event_ \token_to_str:N #1 _prop }
        \msg_error:nnxx { Bhargav } { already-defined }
          { The ~ property ~ list ~ for } { \token_to_str:N #1 }
        \NewDocumentCommand #1 { m }
                { c_Bhargav_event_ \token_to_str:N #1 _prop }
                { ##1 }
              \quark_if_no_value:NTF \l_Bhargav_tmp_tl
                  \msg_error:nnxx { Bhargav } { unknown~property }
                    { \token_to_str:N #1 } { \exp_not:n {##1} }
                { \l_Bhargav_tmp_tl }
          { c_Bhargav_event_ \token_to_str:N #1 _prop }

% defining a new property list

Bhargav Rajyaguru asked a question on \questionDay{} the \questionday{} of
\questionmonth, \questionyear.

It was very sad that Freddie Mercury died on
\deathfreddie{year}-\deathfreddie{month}-\deathfreddie{day}. That was the
saddest \deathfreddie{Month} in \deathfreddie{year}.
  • For now, this solves my issue. However for me it is difficult to understand the property list based approach. Can you provide me some tutorials to understand the property list based approach? For now, I will be using newcommand thing to solve my issue. Nov 11, 2020 at 15:40
  • @BhargavRajyaguru unfortunately, to my knowledge there is no good tutorial for the expl3 syntax yet. If you're somewhat comfortable to write own small macros in (La)TeX and know a thing or two about the oddities of programming in a macro expansion language (like TeX), you can read the documentation provided for the l3kernel (read the document about the interfaces last, that one is the document listing all the available functions with a short description, not a tutorial but a reference manual; the others should be read first to get an idea of the whole thing).
    – Skillmon
    Nov 11, 2020 at 19:39

You must log in to answer this question.

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