
기본적으로 나는 다음과 같은 것을 원합니다. \xspace
즉, 매크로의 의미는 그 뒤에 오는 내용에 따라 달라져야 합니다. 예를 들어 내가 이렇게 말하면
\mymacro a
로 확장될 수 있으며 foo
, 다른 문자가 뒤에 오는 경우 로 확장되어야 합니다 bar
. 내 특별한 경우에는 차이가 있으면 유니코드 문자를 일치시키려고 노력할 것입니다.
편집하다:특히 적분 후 간격에 영향을 미치고 싶습니다. 단독으로 사용할 때는 기본 간격이 적당합니다. 다중 적분 중 첫 번째 적분이라면 공간이 너무 넓어졌습니다. 이전 답변에서 제가 정리한 내용은 다음과 같습니다.
\newcommand\timeintegral[1]{
∫_{t_0}^{t_1} \if ∫#1 \!\!\! \fi #1
}
사용 중인 모습은 다음과 같습니다.
\timeintegral E \, dt = \timeintegral ∫_z ∫_φ f \, dφ dz dt
답변1
이는 다음을 간단하게 적용합니다 \@ifnextchar
.
\documentclass{article}
\usepackage{unicode-math}
\setmainfont{TeX Gyre Pagella}
\setmathfont{Asana Math}
\makeatletter
\newcommand{\timeintegral}{%
∫_{t_0}^{t_1} \@ifnextchar∫{\!\!\!}{}%
}
\makeatother
\begin{document}
\[
\timeintegral E \, dt = \timeintegral ∫_z ∫_φ f \,dφ\,dz\,dt
\]
\end{document}
LaTeX3 버전:
\documentclass{article}
\usepackage{unicode-math}
\setmainfont{TeX Gyre Pagella}
\setmathfont{Asana Math}
\ExplSyntaxOn
\NewDocumentCommand{\timeintegral}{}
{
∫\sb{t\sb{0}}^{t\sb{1}} \psirus_check_int:
}
\cs_new_protected:Npn \psirus_check_int:
{
\peek_charcode_ignore_spaces:NT ∫ { \!\!\! }
}
\ExplSyntaxOff
\begin{document}
\[
\timeintegral E \, dt = \timeintegral ∫_z ∫_φ f \,dφ\,dz\,dt
\]
\end{document}