
Windows에서 PDFLaTeX와 함께 MiKTeX 사용하기
두 개의 미니페이지가 포함된 환경을 만들고 싶습니다. 첫 번째 항목에는 설명 항목이 있고 두 번째 항목에는 작은 텍스트(또는 그림)가 있습니다. 이 코드는 내가 원하는 대로 작동합니다.
{
\noindent
\begin{minipage}{0.5\textwidth}
\begin{description}
\item[Label] Description
\end{description}
\end{minipage}\hfill
\begin{minipage}{0.3\textwidth}
Second minipage
\end{minipage}
}
이런 콘텐츠를 쉽게 소개할 수 있도록 매크로나 환경을 만들고 싶었습니다. 그래서 두 가지 인수를 사용하여 다음 환경을 만듭니다.
\newenvironment{myenvironment}[2]% 1:label, 2:second minipage text
{%
\noindent
\begin{minipage}{0.5\textwidth}
\begin{description}
\item[#1] % Description
}%
{%
\end{description}
\end{minipage}\hfill
\begin{minipage}{0.3\textwidth}
#2
\end{minipage}
}
하지만 내가 그것을 사용하려고 할 때
\begin{myenvironment}{Label}{Second minipage text}
Description text
\end{myenvironment}
Illegal parameter number in definition of \endmyenvironment.
선언 을 끝내는 줄을 가리키게 됩니다 newenvironment
. 이 문제로 몇 시간 고생한 후 이중 해시( )를 사용해 보았지만 ##
두 가지 새로운 오류가 발생했습니다. You can't use `macro parameter character #' in restricted horizontal mode
및 You can't use `macro parameter character #' in internal vertical mode
. 이번에는 환경을 사용하고 싶을 때 오류가 라인을 가리키고 있었지만 정의에 대한 불만은 없었습니다.
내가 도대체 뭘 잘못하고있는 겁니까?
답변1
##
내 문제와는 아무런 관련이 없습니다 . 것 같다사용자 정의 환경의 종료 또는 종료 코드 내에서는 인수를 사용할 수 없습니다.. 이에 대한 해결 방법이 있지만 제 생각에는 이것이가지고 있어야 한다특징. 가능한 해결 방법 ---보조 변수---를 사용하여 다음 작업 환경에 도달했습니다.
\newenvironment{myenvironment}[2]%
{%
\def\myenvargumentII{#2}
\noindent
\begin{minipage}{0.5\textwidth}
\begin{description}
\item[#1] % Description
}%
{%
\end{description}
\end{minipage}\hfill
\begin{minipage}{0.3\textwidth}
\myenvargumentII
\end{minipage}
}
이 솔루션은 늦게 도착했습니다. 그 동안 나는 3가지 \newcommand
인수 를 사용하여 문제를 해결했습니다 .
\newcommand{\myminipages}[3]% 1:label, 2:secondminipage, 3:Description
{%
\noindent
\begin{minipage}{0.5\textwidth}
\begin{description}
\item[#1] #3
\end{description}
\end{minipage}\hfill
\begin{minipage}{0.3\textwidth}
#2
\end{minipage}
\medskip % vertical space
}
다음과 함께 사용할 수 있습니다.
\myminipages{Label}{Second minipage text}{Description text}
도움이 되길 바랍니다.
[a] 적어도 이 용도에서는 접근 방식 newcommand
에 비해 접근 방식 의 특별한 이점이 없는 것 같습니다 . newenvironment
더여기그리고여기.