Redefining commands in a new environment

后端 未结 2 606
深忆病人
深忆病人 2021-02-19 11:03

Two questions:

  1. Does LaTeX allow one to (re)define commands within a \\newenvironment? I\'ve tried using \\renewcommand, \\newcom

相关标签:
2条回答
  • 2021-02-19 11:26

    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}
    
    0 讨论(0)
  • 2021-02-19 11:46

    Sure; it's hard to know what went wrong without seeing your code. As an answer to your two questions, see if this helps:

    \documentclass{article}
    \begin{document}
    \newenvironment{myitemize}{%
      \begin{list}{}{}% whatever you want the list to be
      \let\olditem\item
      \renewcommand\item{\olditem ITEM: }
    }{%
      \end{list}
    }  
    \begin{myitemize}
    \item one \item two
    \end{myitemize}
    \end{document}
    
    0 讨论(0)
提交回复
热议问题