# Amend tabular environment in preamble: different font

I'd like to put some lines in the preamble to change the font of all tabulars in the document. I know that I can easily define my own environment »mytabular«. But for different reasons I need to change tabular. I thought about simply adding (see MWE below) code to the macro, unfortunately without success.

\documentclass{article}

\makeatletter
\makeatother

\begin{document}

This is some text.

\bigskip

\begin{tabular}{lr}
Hello! & 1234 \\
\end{tabular}
\end{document}


Those tabulars will be used outside floats, so it does not help to change something in the table environment.

-
have you looked at the etoolbox? –  cmhughes Jan 5 at 17:35
@cmhughes No. Unfortunately I don't have enough knowledge about TeX and its primitives. –  Keks Dose Jan 5 at 17:38

\documentclass{article}
\let\Tabular\tabular
\let\endTabular\endtabular
\renewcommand\tabular{\sffamily\Tabular}
\renewcommand\endtabular{\endTabular\normalfont}

\begin{document}
This is some text.

\bigskip
\begin{tabular}{lr}
Hello! & 1234
\end{tabular}

foo
\end{document}

-

The etoolbox can help here; in particular, the command AtBeginEnvironment can be used

\AtBeginEnvironment{tabular}{\fontfamily{phv}\selectfont}


Here's the output, and a complete MWE to play with:

\documentclass{article}
\usepackage{etoolbox}

\AtBeginEnvironment{tabular}{\fontfamily{phv}\selectfont}

\begin{document}

This is some text.

\begin{tabular}{lr}
Hello! & 1234 \\
\end{tabular}
\end{document}

-
+1 for introducing \AtBeginEnvironment. –  Who is crazy first Jan 5 at 17:47
Or \preto{\tabular}{\fontfamily{phv}\selectfont}, but one must know the definition of tabular for realizing this is possible. –  egreg Jan 5 at 19:04