TeXnik - Tips TeX and LaTeX


Welcome to the TeXnik website (under construction)

\renewcommand - \renewenvironment
TUG logo

Main page

Index
UK FAQ
Documentation
Software
CTAN
Search CTAN:

Statistics

Google c.t.t.

Google d.c.t.t.

 


 


renewing a latex command or environment with saving the old definition is possible with
\let\newCommand\oldCommand
\renewcommand\oldCommand}{\doThat\newCommand\doThis}
now you can use \newCommand and \oldCommand

Example: an article-layout starts a new section always on the same page. Starting on a new page is possible with

\let\mySection\section
\renewcommand\section{\newpage\mySection}
in this definition \mySection is always the same as the old \section-command.

A \renewcommand inside a new environment looks like

\newenvironment{booglewog}{%
  \renewcommand{\bog}[2]{##1 ##2}%
}{%
}
Otherwise the two Parameters do not belong to \bog.

Especially the definitions for the parts/chapters/sections/... have a star definition, too. If this one should be redefined too, then do it in this way:

Possible Syntax for \foo (\part, \chapter, \section, ...):
  \foo*{...}
  \foo[...]{...}
  \foo{...}
The star is catched by \@ifstar:
\newcommand*{\oldfoo}{}% check, if \oldfoo is free
\let\oldfoo\foo

\renewcommand*{\foo}{%
  \@ifstar{%
    \starfoo
  }{%
    \@dblarg\nostarfoo
  }%
}
\newcommand*{\starfoo}[1]{%
  \dosomethingbefore{#1}%
  \oldfoo*{#1}%
  \dosomethingafter{#1}%
}
\newcommand{\nostarfoo}{}
\def\nostarfoo[#1]#2{%
  % #1: toc entry
  % #2: main entry
  \dosomethingbefore{#2}%
  \oldfoo[{#1}]{#2}%
  \dosomethingafter{#2}%
}

local time: Wed Oct 16 21:15:37 CEST 2019 ; file is: 112.142523148148 days old
contact webmaster _at_ TeXnik.de