Two questions:
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.
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
.
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} .
\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.
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.
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.
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}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With