LaTeX forum ⇒ GeneralWhat does \relax do? Topic is solved

LaTeX specific issues not fitting into one of the other forums of this category.
mgulin
Posts: 18
Joined: Thu May 31, 2012 7:16 pm

What does \relax do?

Postby mgulin » Mon Jul 02, 2012 11:40 am

I'm trying to write my own document class for a report, i.e. to modify little bit LaTeX existing document class report.cls.

So.. I was just wondering, what does \relax command do? For example, I'm rewriting \maketitle command, and there is a bunch of \let\thanks\relax, \let\maketitle\relax etc. Why?

And what does \null\vfil do? :)

Thanks!!

User avatar
cgnieder
Site Moderator
Posts: 1974
Joined: Sat Apr 16, 2011 7:27 pm
Location: Germany
Contact:

Postby cgnieder » Mon Jul 02, 2012 12:54 pm

Hi,

\relax effectively does nothing.

The example \let\thanks\relax in a way undefines \thanks. Now \newcommand*\thanks{<whatever>} wouldn't raise any errors.

In some circumstances \relax can also be used to stop some scanning process like in \ifx\mynum=1\relax (the 1 could just as well be the beginning of a larger number but \relax stops the \ifx from looking).

\null inserts an empty box (it is defined to \hbox{}).

\vfil is a vertical space that can have an arbitrary length (it fills the available vertical space, like \vspace{\fil}).

Regards
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim

User avatar
Stefan Kottwitz
Site Admin
Posts: 8366
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Mon Jul 02, 2012 1:10 pm

\relax does nothing. However, it is unexpandable. In some situations TeX expands commands until it reaches an unexpandable command, that's why \relax can be used to stop expansion or to indicate the end of a command.

Here, \let\thanks\relax causes that a possibly previously defined \thanks command now does nothing.

\null is just an empty (horizontal) box. For example, since some commands have no effect at the beginning of a page, you could insert such an empty box just to have something before such a command, like \vfil or \vfill. Instead of this, you could simply use \vspace*{\fil} or \vspace*{\fill}.

Stefan
Site admin

mgulin
Posts: 18
Joined: Thu May 31, 2012 7:16 pm

Postby mgulin » Mon Jul 02, 2012 3:39 pm

Thanks! This was very helpful!!!


Return to “General”

Who is online

Users browsing this forum: Bing [Bot] and 12 guests