リスト内の自動小文字化

リスト内の自動小文字化

これは非常に単純な質問で、おそらく非常に単純な答えがあると思いますが、私はこれまで見つけることができませんでした。通常のLaTeX2eリスト ( などenumerate) 内の各項目のテキストをすべて小文字で強制的にタイプセットするにはどうすればよいでしょうか。これに関する私の問題は、\lowercaseまたは は\MakeLowercase区切り記号付きの引数を必要とするコマンドであるということです。 は制御シーケンスとして機能するため、これは当てはまりません\item。私の動機は、項目のリスト内のテキストを小文字でタイプセットし、すべての文字を小文字の高さに対応させたい場合がありますが、上記のコマンドを 1 つの ...マニュアルアイテムごとに。最も単純な答え(テキストをすべて小文字で入力するだけ)は、同じテキストを再入力せずに通常のテキストとして使用できるようにしたいため、有用な答えにはなりません\upshape

編集: A. Ellett の提案を回答として選択しました。これは、その機能が私の質問に合っているためであり、それ自体の価値があり、非常によく考えられた貢献であると考えているためです。とはいえ、実現可能であれば、よりシンプルなアプローチも歓迎します。

答え1

この更新バージョン(旧バージョンについては改訂履歴を参照)では、ユーザーが環境に機能を追加する必要はありません。そのようなものは必要ありません。これは、最初のイテレーション\item*で密輸することで可能になり、その後\itemシフト(再定義また)\item詳細なコメントを追加しましたので、このコードをニーズに合わせて変更できるようになります。

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\makeatletter

%% We will use two versions for redefining \item                       
%% The first version is temporary and only used                        
%% for the first iteration.  It's purpose is to                        
%% allow us to slip in an \item just before the                        
%% environment is ended.                                               
\def\@ae@item@va@#1\item#2\@nil{%%
  \def\item##1\end{\@ae@item@vb@##1\@nil}%%
  \@ae@item@vb@#1\item#2\@nil}

\def\@ae@item@vb@#1\item#2\@nil{%%
  %% Don't immediately pass to \olditem                                
  %% we need to see whether there's any optional                       
  %% arguments being passed to \item                                   
  \ae@olditem #1\@nil%%
  %% If second argument is empty, then that means                      
  %% we've parsed the entire environment and should                    
  %% quit.  Restore the "\end" we stole earlier.                       
  \if\relax\detokenize{#2}\relax
    \expandafter\end
  \else
    %% We don't want to get too deeply buried within                   
    %% \if...\fi structures.  So save #2 to a macro                    
    %% then call a dummy macro, but only after first                   
    %% leaving the \if...\fi structure.                                
    \def\ae@tmp{#2}%%
    \expandafter\@@ae@continue@iterating@item
  \fi}

%% Test whether there's an optional argument.                          
\def\ae@olditem{%%
  \@ifnextchar[%]
    {\@o@ae@olditem}
    {\@@ae@olditem}}
\def\@o@ae@olditem[#1]{\olditem[#1] \@@ae@@format}
\def\@@ae@olditem{\olditem \@@ae@@format}
%% The actual formatting of the content following \item
\def\@@ae@@format#1\@nil{%%
  \bgroup\scshape\lowercase{#1}\egroup}
%% The macro handling the continuation of iterating over               
%% the \item's in the environment.  Notice the use of                  
%% \expandafter.  We don't want to pass the formatting                 
%% macro content buried into a temporary macro.  Remember              
%% the \ae@tmp was only used to help us jump out of the                
%% \if ... \fi structure.                                              
\def\@@ae@continue@iterating@item{%%
  \expandafter\item\ae@tmp\end}

\newenvironment{mylc}
  {%%
    \begin{enumerate}
    \let\olditem\item
    %% new definition for \item but only good for first iteration.     
    %% This is how we smuggle in a final \item                         
    %% just before ending the environment.  Here we                    
    %% also steal the `\end` which closes the environment.             
    %% We'll have to restore that before we're done.                   
    \def\item##1\end{%%
      \@ae@item@va@##1\item\@nil}
  }
  {\end{enumerate}}

\makeatother
\def\aerandomstuff{A random string of stuff.}
\begin{document}

  \begin{mylc}
  \item  `A' is for Amy who\ldots
  \item[<optional argument>] This line has an optional argument.
  \item  
  \item  The previous item was empty, but that won't cause us to
         prematurely terminate.
  \item  Matter buried in a macro will not be handled correctly: \aerandomstuff
  \item  This is the last line. No special mark up needed.
  \end{mylc}

\end{document}

ここに画像の説明を入力してください

拡張の問題について: は\lowercase拡張されたコンテンツに対してのみ機能します。私が行うように、密かに持ち込まれたものはすべて、\aerandomstuff最初に小文字に設定されません。

関連情報