Saturday, 15 November 2008

HOWTO: [Lyx] replace the name of bibliography with reference

in lyx, to replace the name of bibliography with reference, using report as document class

marked as TeX

\newcommand \renewcommand

\providecommand{cmd}[args][opt]{def} -- LaTeX2e

These commands define (or redefine) a command.

* cmd The name of the new or redefined command. A \ followed by a string of lower and/or uppercase letters or a \ followed by a single nonletter. For \newcommand the name must not be already defined and must not begin with \end; for \renewcommand it must already be defined. The \providecommand command is identical to the \newcommand command if a command with this name does not exist; if it does already exist, the \providecommand does nothing and the old definition remains in effect.

* args An integer from 1 to 9 denoting the number of arguments of the command being defined. The default is for the command to have no arguments.

* opt (LaTeX2e only) If present, then the first of the number of arguments specified by args is optional with a default value of opt; if absent, then all of the arguments are required.

* def The text to be substituted for every occurrence of cmd; a parameter of the form #n in cmd is replaced by the text of the nth argument when this substitution takes place.


This would allow one to write, e.g.,

The formula for water is \water.


\water\ is the formula for water.

Note, in the second case, the trailing \ followed by a blank is required to ensure a blank space after the H2O; LaTeX ignores the blank following a command, so the space has to be specifically inserted with the \.

As a second example consider


Note that this will produce the desired formula in text (paragraph) mode because of the $...$ in the definition. In math mode, however, the first $ in the definition will cause LaTeX to leave math mode, causing problems.

In LaTeX 2.09 a standard trick for getting around this is to put the math-mode expression in an \mbox, viz.,


In LaTeX2e the \ensuremath command has been provided to alleviate this problem. The argument of the \ensuremath command is always processed in math mode, regardless of the current mode. Using this mechanism the above could be written as


No comments:

My photo
London, United Kingdom

Facebook & Twitter