Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redefining commands in a new environment

Tags:

latex

tex

Two questions:

  1. Does LaTeX allow one to (re)define commands within a \newenvironment? I've tried using \renewcommand, \newcommand and \def in the before declaration but to no avail.

  2. How would one redefine \item when creating a new list environment?

I've created a new type of list environment from scratch using \newenvironment while using another token instead of \item for each but I'd really like to keep things consistent by using \list and redefining \item.

like image 382
gvkv Avatar asked Jan 28 '09 01:01

gvkv


People also ask

How do you define a new environment?

Defining environments with parameters defines a new environment called Example which takes one optional and one mandatory argument. The default value for the optional one will be "Example". You can use this environment with \begin{Example}[inspiring example]{argument} or with \begin{Example}{argument} .

What is the purpose of new command?

\newcommand command is used for defining your own commands (control sequences, macros, definitions); \newcommand must appear (within math delimiters) before it is used; if desired, you can use the TeX. Macros property of the configuration to define macros in the head.

What is an environment in LaTeX?

While TeX makes direct provision for commands, LaTeX adds a concept of “environment”; environments perform an action on a block (of something or other) rather than just doing something at one place in your document. A totally trivial environment could change the font in use for a chunk of text, as.

How do I use Renewcommand in LaTeX?

LaTeX will not allow you to create a new command that would overwrite an existing one. But there is a special command in case you explicitly want this: \renewcommand . It uses the same syntax as the \newcommand command. In certain cases you might also want to use the \providecommand command.


1 Answers

Too late perhaps, but it may be useful for someone else

\newenvironment{coolitemize}{%
\let\olditem\item% 
\renewcommand\item[2][]{\olditem \textbf{##1}\\[0.3\baselineskip]##2}%
\begin{itemize}}{\end{itemize}%
}

and use it

\begin{coolitemize}
\item[Title of my first item] Text of my 1st item.
\item[Second one] And some text here.
\end{coolitemize}
like image 104
user107318 Avatar answered Sep 22 '22 13:09

user107318