사용 사례

사용 사례

tabulararray는 그대로 ... itemize?

다음과 같은 목록을 갖고 싶습니다.

\documentclass{article}
\begin{document}
\begin{eqlist}
\item E=mc^2
\item e^{i\pi}+1=0
\item \text{ducks} + \text{caffeine}
    = \text{\url{https://i.stack.imgur.com/GVksc.gif}}
\end{eqlist}
\end{document}

이미 사용하고 있지만 enumitem사용하지 않습니다.생각하다그 패키지가 도움이 될 거예요. 물론 어떤 솔루션이든 작동합니다 :)

중요한 변형:

  • 디스플레이 수학은 어떻습니까?
  • list같은 다른 환경은 어떻습니까 ?descriptionenumerate

사용 사례

실제로 방정식 목록을 갖는 사용 사례는 매우 간단합니다. 이것을 '재미용'이라고 부를 수 있지만, 저는 과거에 실제로 이와 같은 작업을 수행할 수 있는 수업 노트를 위해 무언가를 해킹한 적이 있습니다(예: 대수 그룹의 속성을 나열하고 이름 지정). 나는 아이디어가 그것에 국한되어 있다고 생각했기 때문에 내 (매우 지저분한) 솔루션을 일반화하지 않았지만 실제로 다양한 문서에서 패턴 팝업이 점점 더 많이 나타나고 있습니다.그렇지 않다예상대로 정말 끔찍해 보입니다. 편리하게도 다음을 제외하고는 확실한 예가 없습니다.reddit.com/r/LaTeX에 나타난 이 초보자 문서.

답변1

여기에 해결책이 있습니다(사용하지는 않지만 와 호환되기를 바랍니다 enumitem).

메모:OP가 디스플레이 수학으로 무엇을 하려는지 이해가 안 됩니다.

한정:빈 줄은 지원되지 않습니다(이 코드는 작동하지 않습니다).

\begin{mathitem}
\item E=mc^2

\item e^{i\pi}+1=0
\item \text{ducks} + \text{caffeine}
    = \text{\url{https://i.stack.imgur.com/GVksc.gif}}
\end{mathitem}

완전한 코드

\documentclass{article}
\usepackage{xpatch}

\usepackage{amsmath,url}
\usepackage{enumitem}


\makeatletter
\newcommand{\mtmathitem}{%
\xpatchcmd{\item}{\@inmatherr\item}{\relax\ifmmode$\fi}{}{\errmessage{Patching of \noexpand\item failed}}
\xapptocmd{\@item}{$}{}{\errmessage{appending to \noexpand\@item failed}}}
\makeatother

\newenvironment{mathitem}[1][]{%
\itemize[#1]\mtmathitem}{$\endlist}                    %$

\newenvironment{mathenum}[1][]{%
\enumerate[#1]\mtmathitem}{$\endlist}                  %$

\newenvironment{mathdesc}[1][]{%
\description[#1]\mtmathitem}{$\endlist}                %$


\begin{document}

\begin{mathitem}
\item E=mc^2
\item e^{i\pi}+1=0
\item \text{ducks} + \text{caffeine}
    = \text{\url{https://i.stack.imgur.com/GVksc.gif}}
\end{mathitem}


\begin{mathenum}
\item E=mc^2
\item e^{i\pi}+1=0
\item \text{ducks} + \text{caffeine}
    = \text{\url{https://i.stack.imgur.com/GVksc.gif}}
\end{mathenum}


\begin{mathenum}[label=\emph{\alph*})]
\item E=mc^2
\item e^{i\pi}+1=0
\item \text{ducks} + \text{caffeine}
    = \text{\url{https://i.stack.imgur.com/GVksc.gif}}
\end{mathenum}

\begin{mathdesc}
\item[some] E=mc^2
\item[thing] e^{i\pi}+1=0
\item[else] \text{ducks} + \text{caffeine}
    = \text{\url{https://i.stack.imgur.com/GVksc.gif}}
\end{mathdesc}

\end{document}

여기에 이미지 설명을 입력하세요

답변2

((i) "MathDescription" 환경을 추가하고 (ii)열거 항목패키지.)

LuaLaTeX 기반 솔루션은 다음과 같습니다. 이는 , 및 이라는 세 가지 새로운 환경을 MathItemize정의 MathEnumerate합니다 MathDescription. 환경은 모든 자료(환경의 설명 레이블 제외 )가 텍스트 모드 대신 수학 모드로 조판된다는 점을 제외하면 "일반" itemize, enumerate및 환경과 동일하게 작동합니다.descriptionMathDescription

필요한 경우 디스플레이 수학 모드에서 항목의 내용을 렌더링하기 위해 \displaystyle뒤에 삽입할 수 있습니다 . \item사용

\item \displaystyle \hfill <formula> \hfill 

디스플레이 수학 자료를 중앙에 설정합니다.

코드가 패키지와 매우 잘 작동하는 것 같습니다 enumitem. 즉, 아래 예제에서는 패키지를 로드하고 및 환경 enumitem의 일부 기본 설정을 변경합니다 .itemizeenumerate

OP의 작성 및 주석에는 중첩 목록이 필요하지 않은 것 같으므로 코드는 중첩되지 않은 목록에 대해서만 작동합니다.

여기에 이미지 설명을 입력하세요

% !TEX TS-program = lualatex
\documentclass{article}
\usepackage{amsmath}      % for "\text" macro
\usepackage{url,hyperref} 
\hypersetup{colorlinks=true}

%% Check compatibility with "enumitem" package...
\usepackage{enumitem} 
\setlist{itemsep=1ex}
\setlist[itemize]{label=$\star$}
\setlist[enumerate]{label=\roman*), leftmargin=*, widest = iii}

\usepackage{luacode,luatexbase}
%% Lua-side code: Three Boolean variables, two new
%% functions, & calls to assign the new functions to 
%% the "process_input_buffer" callback
\begin{luacode}
env_type_1 = false
env_type_2 = false
first_list_item = true

function change_item_properties_itemenum ( line )
  if (env_type_1 == true) then
    if (first_list_item == true) then
        line = string.gsub( line, "\\item", "\\item $" )
        first_list_item = false
    else 
        line = string.gsub( line, "\\item", "$ \\item $" )
    end  
  end  
  return (line)
end

function change_item_properties_desc ( line )
  if (env_type_2 == true) then
    if (first_list_item == true) then
        line = string.gsub( line, "(\\item.-%[.-%])", "%0 $" )
        first_list_item = false
    else 
        line = string.gsub( line, "(\\item.-%[.-%])", "$ %0 $" )
    end  
  end  
  return (line)
end

luatexbase.add_to_callback ( "process_input_buffer",
        change_item_properties_itemenum, 
        "MathModeItemizeEnumerate" )
luatexbase.add_to_callback ( "process_input_buffer",
        change_item_properties_desc, 
        "MathModeDescription" )
\end{luacode}

%% TeX-side code -- Three new environments: 
%% MathItemize, MathEnumerate, MathDescription
\newenvironment{MathItemize}%
  {\directlua{ env_type_1 = true }
   \begin{itemize} }%
  {$\end{itemize}
   \directlua{ env_type_1 = false 
               first_list_item = true}}
\newenvironment{MathEnumerate}%
  {\directlua{ env_type_1 = true }
   \begin{enumerate}}%
  {$\end{enumerate}
   \directlua{ env_type_1 = false 
               first_list_item = true}}
\newenvironment{MathDescription}%
  {\directlua{ env_type_2 = true }
   \begin{description}}%
  {$\end{description}
   \directlua{ env_type_2 = false 
               first_list_item = true}}

\begin{document}

\noindent
A \verb+MathItemize+ list
\begin{MathItemize}
\item E=mc^2
\item e^{i\pi}+1=0
\item \text{ducks} + \text{caffeine}
    = \text{\url{https://i.stack.imgur.com/GVksc.gif}}
\end{MathItemize}

\bigskip\noindent
An ``ordinary'' \verb+itemize+ list
\begin{itemize}
\item Hello world.
\item Goodbye world.
\end{itemize}

\bigskip\noindent
A \verb+MathEnumerate+ list
\begin{MathEnumerate}
\item a^2+b^2=c^2
\item \displaystyle \hfill \sum_{k=1}^\infty \frac{1}{k^2} = \frac{\pi^2}{6} \hfill
\item 1+1=2
\end{MathEnumerate}

\bigskip\noindent
A \verb+MathDescription+ list
\begin{MathDescription}
\item [Einstein] \hfill  E=mc^2 \hfill 
\item[Euler] e^{i\pi}+1=0
\item  [Pythagoras] a^2+b^2=c^2
\end{MathDescription}

\bigskip\noindent
Finally, an ``ordinary'' \verb+enumerate+ list
\begin{enumerate}[widest=ii] 
\item abcdef, and
\item uvwxyz.
\end{enumerate}

\end{document}

답변3

빠르고 더러운:

\documentclass{article}

\makeatletter
\newif\if@mathitemize
\newif\if@closemathitem
\let\orig@item=\item
\renewcommand{\item}{\if@closemathitem$\fi\orig@item\if@mathitemize\@closemathitemtrue$\fi}
\newenvironment{mathitemize}{\@mathitemizetrue\itemize\@closemathitemfalse}{$\enditemize}
\makeatother

\begin{document}

\begin{itemize}
\item test
\item test2
\end{itemize}

\begin{mathitemize}
\item E=mc^2
\end{mathitemize}

\end{document}

여기에 이미지 설명을 입력하세요

관련 정보