新环境中没有括号的新命令

新环境中没有括号的新命令

我已经创建了一个新的环境来制作注释列表,它经过改编,itemize没有符号:

\documentclass{report}
\usepackage{mathtools}
\newenvironment{clist}
    {\newcommand\com[2][1cm]{\par{\small\rule{##1}{0pt}\parbox{\linewidth-##1}{##2}}\par}\renewcommand\labelitemi{}\begin{itemize}}
    {\end{itemize}}
\begin{document}
\begin{clist}
  \item First thing
  \item Second thing
    \com{This thing was good!}
  \item Last thing
\end{clist}
\end{document}  

\small注释段落默认缩进 1cm,可选\com参数设置缩进大小。

我的问题是 - 如何让 \com 像 \item 一样不需要括号?这样我就可以写评论段落了

\com Like this?

我并不关心是否有一个软件包可以轻松完成这项工作;我希望能够以各种方式自定义这类事情,并了解如何做到这一点,不一定非要使用itemize或列出其他更简单的方法。或者也许这太棘手了,不值得为此烦恼。

答案1

enter image description here

\documentclass{article}
\pagestyle{empty}
\usepackage{paralist,lipsum}

\newcommand{\Com}[1][4]{%
    \xdef\MySkip{\leftskip#1em}%
    \item[\aftergroup\MySkip\aftergroup\footnotesize]}
\makeatletter

\newcommand{\savefont}{%
    \xdef\oldfontsize{\f@size}%
    \xdef\oldblskip{\f@baselineskip}}

\newcommand{\backtoppevfont}{%
     \fontsize{\oldfontsize}{\oldblskip}\selectfont}

\makeatother

% Take one optional argument
% item caracter ex $\bullet$
\newenvironment{Itemize}[1][]{%
    \savefont%
    \def\FntSz{\fontsize{\MyL}{\MyL}\selectfont}%
    \begin{list}{%
        \xdef\MySkipBack{\leftskip0em}%
        \backtoppevfont#1\aftergroup\backtoppevfont\aftergroup\MySkipBack}{%
        \setlength{\labelwidth}{0em} % adapt as you want
        \setlength{\leftmargin}{0pt}
        \setlength{\itemindent}{\parindent} % indentation here
    }}{%
    \end{list}}


\begin{document}

\lipsum[1]

Let's make an list :

\begin{Itemize}
\item \lipsum[2]
\addtolength{\parindent}{10pt}
\Com \lipsum[3]
\item Two
\item Three
\Com This is my comment
\end{Itemize}

\end{document}

答案2

正如 David C 所说,抓取到第一段的结尾并不太难。这里有一个版本可以做到这一点。它依赖于每个评论后面的空白行(新段落)。

\documentclass{report}
\usepackage{mathtools}
\newenvironment{clist}
   {\renewcommand\labelitemi{}\def\com##1\par{\par\rule{2em}{0pt}\parbox{%  
\linewidth-2em}{\small##1}}\begin{itemize}} 
    {\end{itemize}}
\begin{document}
\begin{clist}
  \item First thing
  \item Second thing 
    \com This thing was good! This thing was good! This thing was good! This  
thing was good! This thing was good! This thing was good! 

  \item Last thing
\end{clist}
\end{document}

(如果您没有现有的命令\com...这不会造成问题)

TeX 宏参数 101:第一个\par分隔\com的参数;也就是说,TeX\par在注释中寻找 - LaTeX 代码中的新段落/空行 - 以了解参数何时结束。它可以被其他东西替换。如果用句号替换 - \def\com##1.- 那么不需要新段落/空行,注释只需要一个.来结束它们。

相关内容