LaTex Annoyances

I really like LaTex. I much prefer to typset my papers, rather than manufacture them in word. But every once in a while, I find little things that make using LaTex a PITA.

For example, in my document, I have text that often needs to be repeated. For example, I need the title on the titlepage (duh), the copyright page, the signature page and etc… Same goes for actor. I spent countless hours searching how to extract data from the built in variables initialized via the standard \author and \title calls. I even emailed my old mentor in all things LaTex and he also had no clue.

So I decided to fake it:

\newcommand{\printtitle}{Title of My Paper}

Now wherever I need to put title, I just use \printtitle and I’m done. This is not a perfect solution, but it works. At least as long as you don’t start nesting functions. For example if you do:

\uppercase{\printtitle}

You get lowercase letters. Why? Latex does not have a proper stack, and so nesting functions may or may not work depending on circumstances. At least that’s what I have been told.

This is annoying as shit. Anyone knows the proper way to do this? I know that the answer must be locked up somewhere deap within article.cls which includes the implementation of the \maketitle call. But for the life of me, I can’t decipher how to extract title and author from there.

This entry was posted in programming and tagged . Bookmark the permalink.



14 Responses to LaTex Annoyances

  1. Lee UNITED STATES Mozilla Firefox Windows says:

    Regarding your title problem, this will get you the text:

    \makeatletter\@title\makeatother

    but it still barfs if you try to use \uppercase

    hope this helps.

    Reply  |  Quote
  2. Luke UNITED STATES Mozilla Firefox Windows says:

    Wow! Thanks for the tip! I couldn’t figure that out.

    I’m wondering if \protect will do anything in this case…

    Reply  |  Quote
  3. Use the LaTeX rather than the TeX form:

    \MakeUppercase{\printtitle}

    and it will be in uppercase. ;)

    Another command to know is TeX’s \edef which expands the definition before it is stored. However, as with \def, you have to be careful as it will not warn you if an existing command is overwritten.

    Reply  |  Quote
  4. Luke UNITED STATES Mozilla Firefox Ubuntu Linux says:

    Thanks! This thing was driving me nuts!

    Reply  |  Quote
  5. I forgot to mention one more trick. This:

    \expandafter\uppercase\expandafter{\printtitle}

    will also work. All of this is related the problem of how far TeX should expand a macro before performing an operation on it. It isn’t so much a design flaw or limitation of TeX, but rather a difficulty in specifying to it exactly what you want to do. Obviously, \uppercase, unlike \MakeUppercase, does not do an expansion on its argument before it operates on it.

    Reply  |  Quote
  6. Luke UNITED STATES Mozilla Firefox Ubuntu Linux says:

    Thanks! Those are really great tips.

    See, sometimes I miss this kind of insights – I have functional understanding of LaTex but every once in a while I run into a problem that reminds me that I still have tons to learn about it. :)

    Reply  |  Quote
  7. Surajit Das INDIA Internet Explorer Windows says:

    I want to write the Heading: “References” in place of “Bibliography” for the heading of Bibliography. How can i do that?

    Reply  |  Quote
  8. Luke UNITED STATES Mozilla Firefox Windows says:

    Surajit – try this:

    \renewcommand\bibname{References}

    This should do the trick.

    Reply  |  Quote
  9. Surajit Das INDIA Internet Explorer Windows says:

    Many many thanks Luke, it worked!

    Reply  |  Quote
  10. Luke UNITED STATES Mozilla Firefox Windows says:

    Glad to help. :)

    Reply  |  Quote
  11. Surajit Das INDIA Internet Explorer Windows says:

    I dont want to put the page number of the bibliography in the content of my report. How can i do that?

    Reply  |  Quote
  12. Luke UNITED STATES Mozilla Firefox Ubuntu Linux says:

    Not sure what you mean. Can you explain?

    Reply  |  Quote
  13. Surajit Das INDIA Internet Explorer Windows says:

    Can i use the “.sty” files while i am in windows Xp platform? If so, then how can i do that? I want to use the Sty files such as fancyheadings.sty, nomencl.sty etc.

    Reply  |  Quote
  14. Luke Maciak UNITED STATES Mozilla Firefox Windows says:

    Why wouldn’t you? If you have a fancy custom style you can just drop it in the same directory as the file you are working on. If you want to install a package for a system wide use you should probably consult instructions for your latex distribution as the paths may vary.

    Reply  |  Quote

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>