수학 모드에서 쉼표 뒤에 공백을 두세요.

수학 모드에서 쉼표 뒤에 공백을 두세요.

나는 이 질문에 대한 답을 열심히 찾아보았지만 찾을 수 없었습니다. 기사를 입력하고 있는데 수식을 많이 작성해야 하는데 저 f(x, y)에게는 f(x,y). 수학 모드에서 항상 쉼표 뒤에 얇은 공백을 쓰는 것이 지겹고 \,혼란스럽습니다. 이것을 자동화하는 방법이 있나요?

답변1

나중에 더 많은 공간을 확보하고 싶다면모든수학 모드의 쉼표.

\documentclass{article}

\AtBeginDocument{%
  \mathchardef\stdcomma=\mathcode`,
  \mathcode`,="8000
}
\begingroup\lccode`~=`, \lowercase{\endgroup\def~}{\stdcomma\,}

\begin{document}

$f(x,y)$

$a,b,c$

\end{document}

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

변수를 지정할 때 공백만 원하는 경우 package 와 동일한 방법을 사용할 수 있지만 icomma입력 시 규칙이 필요합니다. 쉼표 뒤에 공백이 오면(수학 모드에서) 얇은 공백이 추가됩니다.

\documentclass{article}

\makeatletter
\AtBeginDocument{%
  \mathchardef\stdcomma=\mathcode`,
  \mathcode`,="8000
}
\begingroup\lccode`~=`, \lowercase{\endgroup\def~}{%
  \futurelet\@let@token\spaced@comma
}
\newcommand{\spaced@comma}{%
  \stdcomma
  \ifx\@let@token\@sptoken\,\fi
}
\makeatother

\begin{document}

$f(x, y)$ % added space

$f(x,y)$ % compare with the standard

$a,b,c$ % no space is added

\end{document}

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

\thinmuskip더 큰 값으로 설정하는 것을 피하겠습니다 . 이유는 다음과 같습니다.

\documentclass{article}

\thinmuskip=6mu

\begin{document}

$f(x,y)=\sin x-\sin y$ % with the new setting

\thinmuskip=3mu

$f(x,y)=\sin x-\sin y$ % with the standard setting

\end{document}

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

보시다시피 \thinmuskip는 쉼표 뒤에만 사용되는 것이 아니라 같은 확대된 공간의 영향을 받는 다른 여러 위치에서도 사용됩니다.

답변2

,\mathpunct설정을 변경하지 않는 한 기본적으로 공간이 얇습니다 . 비교{,}

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

\documentclass{article}

\begin{document}

$f(x, y)$

$f(x{,} y)$

\end{document}

답변3

원하는 공백으로 자신만의 명령을 정의할 수도 있습니다.

\documentclass{article}

\newcommand{\fxy}{$f(x,\,y)$}

\begin{document}
    \fxy, compared to
    

    $f(x,y)$
    
\end{document}

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

관련 정보