26 October 2008 by Stefan Kottwitz
Sometimes I want to redefine a macro of a class or package but want to use its original definition. Instead of copy&paste one could use the original macro directly:
- come up with a new macro, ensure that it’s not defined yet,
- save the definition of the original macro to the new macro,
- redefine the original macro using the new macro with the saved original code,
I will give a very simple example for a demonstration. Today a LaTeX Community member said that he’s using the quote environment but wants the enclosed text to have a smaller size. A straightforward solution is to use \renewenvironment copying the original code, let’s say from article.cls, and to make a small modification:
\renewenvironment{quote}
{\list{}{\rightmargin\leftmargin}%
\item\relax\small}
{\endlist}
Just the \small was added. This solution needs the writer to examine the class source, that may also be changed later.
The second solution is the method I’ve described above:
\newcommand*\origquote{}
\let\origquote\quote
\renewcommand*\quote{\origquote\small}
The \newcommand line may be omitted, I’ve just used it to ensure that an error would be raised if a macro with that name was already defined by somehing else.
The last code works like the first solution, but respects the original class code and it will also respect further changes of the class, therefore I’m preferring it.
But the third solution is similar, shorter and doesn’t need the creation of another macro. It’s doing the same job but uses the original macro directly, avoiding a recursion problem by using \expandafter:
\expandafter\def\expandafter\quote\expandafter{\quote\small}
You can find the same method applied in my comment to a previous blog post.
If you want to know how expandafter works you will find explanations in TeX books and documentations. Further there’s an extensive tutorial by Stephan v. Bechtolsheim (TUGboat, Volume 9, 1988), old but still valid of course.
This topic was discussed in the LaTeX Community Forum and on Matheplanet.com.
Category: LaTeX General, plain TeX |
No Comments »
26 July 2008 by Stefan Kottwitz
Recently Michael Downes collection of TeX challenges “Around the Bend“, originally in ASCII format, has been typeset in pdf format by Peter Wilson and has now been released on CTAN.
The document contains exercises posing a problem and one or several solutions.
Category: plain TeX |
No Comments »
12 July 2008 by Stefan Kottwitz
The very recommendable book TeX by Topic by Victor Eijkhout, originally published by Addison-Wesley 1991, is now available printed and bound from lulu.com. The author himself announced it today in the usenet group comp.text.tex.
The book has been published under GNU Free Documentation License 2007 and will remain downloadable from savannah.nongnu.org. It’s also available on the author’s homepage.
Even if it’s freely available I recommend to purchase this really great book to support the author. And of course to have a printed version. Its 319 pages are paperback bound to keep the price low at €11.30.
Category: plain TeX |
No Comments »
12 July 2008 by Stefan Kottwitz
Yet again somebody in the mrunix forum asked for an advice how to put the frame number into the footline of his beamer presentation. He was using the “Warsaw” outer theme. The first solution
\setbeamertemplate{footline}[frame number]
will just overwrite the “Warsaw” footline.
Possible solutions are: to use a different outer theme or to change the “Warsaw” footline. “Warsaw” uses the split outher theme, a workaround for insertion of the frame number should consider that and will be usable for other themes like “Copenhagen”, “Luebeck” and “Malmoe”. Inspection of the file beamerouterthemesplit.sty reveals that the footline uses the \insertshorttitle macro in its right part. So a quick workaround could be to redefine that macro:
\newcommand*\oldmacro{}%
\let\oldmacro\insertshorttitle%
\renewcommand*\insertshorttitle{%
\oldmacro\hfill%
\insertframenumber\,/\,\inserttotalframenumber}
If you want to see more details you could look at example source code and its pdf output.
This topic was discussed on mrunix.de and in the Matheplanet forum.
Category: Presentations, plain TeX |
1 Comment »
11 July 2008 by Stefan Kottwitz
The new stable release of pdfTeX 1.40.8 has been released. pdfTeX is an extended TeX version with the ability to create pdf files directly from TeX source files supporting pdf specific features. Changes include:
- Implementation of SyncTeX,
- incorporated the new TeX version 3.1415926,
- use of the current public release libpng 1.2.29,
- bugfixes.
For more information see pdfTeX News page on tug.org.
Category: plain TeX |
No Comments »
21 June 2008 by Stefan Kottwitz
The package hyph-utf8 has been released today. It contains hyphenation patterns that have been converted into UTF-8, addressing the need for appropriate patterns by native UTF-8 engines such as XeTeX.
For more information see the README file on its location on CTAN and tug.org/tex-hyphen.
Category: plain TeX |
No Comments »