음수 부호가 공간을 차지하지 않도록 만들기

음수 부호가 공간을 차지하지 않도록 만들기

공간을 차지하지 않는 텍스트를 만드는 방법을 자세히 설명하는 게시물을 이미 읽었습니다. 내 질문은 이 경우에 내가 올바르게 수행하고 있는지입니다.

\documentclass{article}

\usepackage{mathtools}

\newcommand{\n}{\makebox[0pt][r]{$-$}}

\begin{document}
Not using my custom command
\begin{alignat*}{3}
  a_1 & {}-{} & a_2 & {}={} & -3\\
      && a_2 & {}={} & 8\\
      && - a_2 & {}={} & 8
\end{alignat*}

Using my custom command
\begin{alignat*}{3}
  a_1 & {}-{} & a_2 & {}={} & -3\\
      && a_2 & {}={} & 8\\
      && \n a_2 & {}={} & 8
\end{alignat*}
\end{document}

명령이 \n약간 해킹된 것 같아서 내 문제에 대한 더 나은 해결 방법이 있는지 궁금합니다.

답변1

당신의 정의는 실제로 해키가 아닙니다. 다음을 사용하여 좀 더 간단하게 정의할 수 있습니다 \llap.

\newcommand\n{\llap{$-$}}

\llap및 는 본질적으로 및 와 각각 \rlap동일합니다 .\makebox[0pt][r]\makebox[0pt][l]

답변2

더 좋은 방법이 있습니다: 패키지 systemeautoaligne. 전자는 구문이 더 간단하고 후자는 더 강력하지만 용어가 누락된 경우 조금 더 어렵습니다.

\documentclass{article}

\usepackage{autoaligne}
\usepackage{systeme}
\usepackage{regexpatch}

% see http://tex.stackexchange.com/questions/247070/
\makeatletter
\xpatchcmd{\SYS@makesyspreamble@i}
  {$##$\hfil\null}% left alignment
  {\hfil$##$\null}% right alignment
  {}{}
\makeatother

\begin{document}
\[
\sysdelim..
\systeme{
  a_1 - a_2 = -3,
  a_2 = 8,
 -a_2= -8
}
\]

\[
\autoaligne[dd]{%
a_1-a_2=-3 \\%
+a_2=8 \\
-a_2=-8
}
\]

\end{document}

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

답변3

올바른 사용법은 alignat일을 훨씬 간단하게 만듭니다. n개의 정렬 그룹에는 2n – 1개의 앰퍼샌드가 필요하다는 점을 기억하세요. 실제로 여기에서는 두 그룹이면 충분합니다.

\documentclass{article}

\usepackage{mathtools}

\begin{document}

\begin{alignat*}{2}
  a_1- a_2 &={} & -3 & \\
       a_2 &= & 8 & \\
       - a_2 & = & 8 & %
\end{alignat*}

\end{document} 

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

관련 정보