TeXblog

 Typography with TeX and LaTeX

Archive for September, 2008

An extension to amsmath matrix environments

September 30th, 2008 by Stefan Kottwitz

Inspired by a question on matheplanet.com and remembering the cases redefinition I’ve shown some days ago I got the idea to extend the internal macro \env@matrix of amsmath.sty. I wanted to use the matrix environments together with array features like alignment, vertical lines, formatting and special commands.
The mathtools package provides something similar by its starred matrix environments that support one optional parameter that will be applied to all matrix columns. The following redefinition will introduce an optional parameter to amsmath array environments that allows column-specific customization:

\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
  \hskip -\arraycolsep
  \let\@ifnextchar\new@ifnextchar
  \array{#1}}
\makeatother

If you put these lines into your document preamble the pmatrix, bmatrix, vmatrix, Bmatrix, Vmatrix etc. environments will accept an optional parameter. If you don’t provide this parameter those environments will work like usual. Here’s one example showing an augmented matrix containing a vertical line:

\[
\begin{pmatrix}[cc|c]
  1 & 2 & 3\\
  4 & 5 & 9
\end{pmatrix}
\]
augmented matrix

Another more complex example just showing some array features like different alignment because of the signs, color change and bold font:

\[
\begin{bmatrix}[*2cr@{\quad}|@{\quad}>{\bf\color{red}}r]
  a & b & 1  &  4 \\
  c & d & -2 & -3
\end{bmatrix}
\]
augmented matrix

Though \bf is an obsolete font command standard classes still support it and I’ve just used it because \boldmath is invalid in math mode, in general I advice against using \bf.

Category: Mathematics | 5 Comments »

How to get rid of those beamer warnings

September 27th, 2008 by Stefan Kottwitz

Many users of the beamer class are irritated by several beamer warnings at every compiler run that are not caused by themselves, I’m referring to the beamer version 3.07. Those warnings are not really important, but it’s a good habit to debug all warnings instead of just ignoring them, otherwise an important warning could easily be overlooked.

When I compile this really small example:

\documentclass{beamer}
\begin{document}
\begin{frame}
Test
\end{frame}
\end{document}

I’m getting 6 warnings, after the second compilation of course less, but these 4 warnings remain:

  1. Package pgf Warning: This package is obsolete and no longer needed on input line 13.
  2. Package hyperref Warning: Option `pdfpagelabels’ is turned off
    (hyperref) because \thepage is undefined.
    Hyperref stopped early
  3. LaTeX Font Warning: Font shape `OT1/cmss/m/n’ in size <4> not available
    (Font) size <5> substituted on input line 6.
  4. LaTeX Font Warning: Size substitutions with differences
    (Font) up to 1.0pt have occurred.

Let’s eliminate those warnings:

  1. beamer.cls is loading the obsolete package pgfbaseimage.sty that does nothing but loads pgfcore and prints out this warning. If you put a file with the same name pgfbaseimage.sty somewhere into your texmf directory (TEXMFHOME for example) or into the directory of your tex document containing just the line \RequirePackage{pgfcore} the warning will disappear.
  2. Set pdfpagelabels to false by yourself, by providing a beamer class option: hyperref={pdfpagelabels=false}
  3. beamerbasefont.sty defines the commands \Tiny and \TINY to choose very small font sizes. Redefine at least \Tiny or load a font providing that size, for instance Latin Modern.
  4. fixed by 3.

The new file:

\documentclass[hyperref={pdfpagelabels=false}]{beamer}
\let\Tiny=\tiny
\begin{document}
\begin{frame}
Test
\end{frame}
\end{document}

will not cause warnings any more. Using those workarounds you won’t be annoyed by unnecessary warnings during development of presentations. Though the redefinition of \Tiny will fix it for Computer Modern fonts I recommend to consider to use Latin Modern instead:

\usepackage{lmodern}

Category: Presentations | 46 Comments »

amsmath: cases and \arraystretch

September 24th, 2008 by Stefan Kottwitz

The amsmath cases environment is using the array environment internally, like its matrix environments. If you want to change the interline spacing of matrices you could redefine \arraystretch, like for any array environment. But it won’t work for cases - amsmath defines an arraystretch value of 1.2 internally.

A solution is to redefine the \env@cases macro. Here’s a redefinition, introducing an optional parameter controlling the spacing:

\makeatletter
\renewcommand*\env@cases[1][1.2]{%
  \let\@ifnextchar\new@ifnextchar
  \left\lbrace
  \def\arraystretch{#1}%
  \array{@{}l@{\quad}l@{}}%
}
\makeatother

Now by \begin{cases} … \end{cases} the default value of 1.2 will be used, but by using the optional parameter like \begin{cases}[0.8] … \end{cases} the spacing will be adjusted accordingly.

This topic was discussed on mrunix.de.

Category: Mathematics | 6 Comments »

TeXnicCenter: new homepage design

September 20th, 2008 by Stefan Kottwitz

TeXnicCenter

The TeXnicCenter homepage has got a new design, as Sven announced today in the LaTeX Community Forum. Now it has a more modern look and provides better access to its contents.

TeXnicCenter is an integrated development environment for LaTeX, running on the Windows platform. It’s supporting both MiKTeX and TeX Live. The version 2.0 is now under development as you can read in the news section.

Category: News, IDEs and Editors | 10 Comments »

Software Freedom Day 2008

September 18th, 2008 by Stefan Kottwitz

software freedom day 08

The Software Freedom Day is a worldwide celebration of Free and Open Source Software. The goal in this celebration is to educate the worldwide public about of the benefits of using high quality free and open source software in education, in government, at home and in business. The non-profit company Software Freedom International coordinates this event at a global level, volunteer teams around the world organize local SFD events. Already over 500 teams in over 90 countries all around the world have announced to celebrate the SFD.

One event will take place September 20th, 2008 in Berlin, supported by FSFE and FFII Berlin. You can find more details here: Team Freie Software Berlin.

Category: News, Events | 2 Comments »

Centering wide tables or figures

September 17th, 2008 by Stefan Kottwitz

When you want to include an image or a table that’s wider than the text width, you will notice that even when \centering or the center-environment is used this wide object will not be centered in relation to the surrounding text. It will be placed at the left margin but go into the right margin. Its frequently requested that wide figures or tables should overlap at both sides in equal measure.

It can easily achieved by putting the table or picture inside a box, giving the box the width of the text, by the \makebox command. Here is a compilable example, where I’m centering a table having 1.5 times the width of the text:

\documentclass[a4paper,10pt]{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{tabularx}
\begin{document}
 
\blindtext
\bigskip
 
\noindent\makebox[\textwidth]{%
\begin{tabularx}{1.5\textwidth}{XX}
  \blindtext & \blindtext
\end{tabularx}}
 
\bigskip
\blindtext
 
\end{document}

I’ve used \noindent to suppress the paragraph indentation, otherwise I would get an overfull \hbox. As you may notice there’s no \centering necessary because the width of the box equals \textwidth.

This topic was discussed in the LaTeX Community Forum, on CQF.info and on mrunix.de.
.

Category: Figures and Tables, Layout | 30 Comments »

Writing scientific documents using LaTeX

September 16th, 2008 by Stefan Kottwitz

Today it has been announced that a new paper “Writing scientific documents using LaTeX” by Andrew J. Bennieston has been uploaded to CTAN, an introduction on 13 pages. I took a brief glimpse at this paper.
Nice to have another introduction, but some odd things catched my eye. The author introduces $$…$$ as shortcut form for display math mode without equation numbering, but \[…\] is recommended instead of this, like mentioned in “Obsolete packages and commands“, $$…$$ should be avoided. The author describes also the obsolete math environment eqnarray. Though he is mentioning that the align environment should be preferred he didn’t say why. As one can see in the output of the equations (2), (3) and (4) there’s something wrong with the spacing next to the relation symbol, the author just didn’t use eqnarray correctly, there’s a & separation symbol missing on each line. It’s compilable, but if you extend the right side then the = symbols will not be aligned any more, compare the syntax with this reference. The right sides of those equations including the = symbol are actually centered, not noticeable because they are having equal width.
This article contains also a wrong syntax of the align environment. The demonstration example doesn’t contain any & separation symbol, the alignment is just a coincidence.

I’m referring to the fourth Edition of September 13, 2008, uploaded to CTAN today. I’m expecting that the mistakes will be corrected soon, of course I will send the author an email containing my comments.

Category: LaTeX General, Mathematics | 1 Comment »

Kpfonts 2.3 released

September 15th, 2008 by Stefan Kottwitz

The version 2.3 of the font package kpfonts has been released on CTAN as announced today over the ctan-ann mailing list. Kpfonts provide an extensive set of fonts for LaTeX including roman, sans-serif, monospaced and math symbol fonts in regular and bold shape, true small caps and more.
The current release introduces

  • a new option nofligatures with no fi, fl, ff, ffi and ffl ligatures and redesigned f glyphs to achieve better results,
  • a new shape with slanted small caps.
  • improved small caps kerning.

To get more information have a look at the documentation.

Category: News, Fonts and Symbols | No Comments »

Paper sizes with pdfTeX

September 12th, 2008 by Stefan Kottwitz

I’m frequently noticing questions regarding problems with paper size and pdfLaTeX, for instance Bug 215561 and Bug 244043 on Launchpad, yesterday on mrunix.de and also yesterday on matheplanet.com.
If you manually change \paperwidth or \paperheight or use the landscape option of LaTeX classes like for instance article it could happen that the paper size of the resulting pdf differs.
A solution is to adjust the \pdfpagewidth and \pdfpageheight values:

\setlength{\pdfpagewidth}{\paperwidth}
\setlength{\pdfpageheight}{\paperheight}

To use the geometry package could correct it too. But if you use it together with gmeometric, it may still be necessary to adjust the pdf page size like written above, see for instance goLaTeX.de.

Category: TeX Live, Layout | No Comments »

TeX Live 2008 released

September 3rd, 2008 by Stefan Kottwitz

TeX Live 2008 is now officially released. This information was posted by Karl Berry to comp.text.tex yesterday, though it’s been available for download since some days already. In this version the underlying package infrastructure has been redesigned and reimplemented, it allows dynamic package updates over the internet like with MiKTeX for years. That’s a big step forward!
You can find more information about new and changed features by reading the original release notes.

See also:

Category: TeX Live, News | No Comments »