0

Based on the question How to rename or "copy" a latex environment I am tried to rename the comment environment to myenvironment:

\documentclass[10pt,a5paper,twoside]{memoir}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage[brazil]{babel}
\usepackage[showframe,pass]{geometry}

\usepackage{comment}

\makeatletter

% \newenvironment{myenvironment}{\comment}{\endcomment}

\let\myenvironment\comment
\let\endmyenvironment\endcomment

\makeatother

\begin{document}

    This is normal text.

\begin{myenvironment}

         How to make this environment be \bfseries{verbatim}?

\end{myenvironment}

\end{document}

However it do the error:

Excluding 'comment' comment.)
Runaway argument?
! File ended while scanning use of \next.
<inserted text> 
                \par 
<*> ./test2.tex

I suspect you have forgotten a `}', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.

! Emergency stop.
<*> ./test2.tex
user
  • 4,745
  • 2
    Perhaps you should start to read some documentation. The one from comment explictly describes how to create new comment like environments. – Ulrike Fischer Aug 21 '17 at 17:51
  • Sorry, I just did it I wrote a wrong question. – user Aug 21 '17 at 17:52
  • The comment package allows I create new environment with \excludecomment{myenvironment}, and the verbatim accepted doing \let\myotherenvironment\verbatim to be renamed correctly. – user Aug 21 '17 at 17:54
  • 1
    Related: https://tex.stackexchange.com/questions/116670/duplicating-environments – Steven B. Segletes Aug 21 '17 at 17:57

1 Answers1

1

The question code was badly tested:

  1. The comment environment can be "renamed" by creating new environment version with its macro \excludecomment{myenvironment}
  2. The verbatim environment accepted correctly to be renamed with \let\myotherenvironment\verbatim and \let\endmyotherenvironment\endverbatim:

Example:

\documentclass[10pt,a5paper,twoside]{memoir}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage[brazil]{babel}
\usepackage[showframe,pass]{geometry}

\usepackage{lmodern}
\usepackage{comment}

% How to rename an existing command?
% https://tex.stackexchange.com/questions/193379/how-to-rename-an-existing-command
\newcommand{\supertiny}{\fontsize{2pt}{2.5pt}\selectfont}

\excludecomment{myenvironment}
\newenvironment{myotherenvironment}{\verbatim\supertiny}{\normalfont\endverbatim}

\begin{document}
     This is normal text.

\begin{myenvironment}
     How to make this environment be a comment?
\end{myenvironment}

\begin{myotherenvironment}
     How to make this environment be {\bfseries verbatim}?
\end{myotherenvironment}

\end{document}

enter image description here

user
  • 4,745