분수가 포함된 증강 행렬

분수가 포함된 증강 행렬

일부 증강 행렬을 조판해야 하는데 그 중 일부에 분수가 포함되어 있습니다. gmatrix기능이 필요하기 때문에 로도 그렇게 해야 합니다 .

다음 코드는 항목 사이에 줄을 만드는 데 사용됩니다.

\newcommand{\mline}{%
  \hspace{-\arraycolsep}%
  \strut\vrule
  \hspace{-\arraycolsep}%
}

이를 통해 다음과 같은 것을 만들 수 있습니다.

예: 분수가 없는 증대 행렬

암호:

\begin{align} 
    \begin{gmatrix}[p] 
        1 & 2 & 3 & \mline & 40 \\
        2 & 3 & 4 & \mline & 500 \\
        3 & 4 & 5 & \mline & 6000
    \end{gmatrix} 
\end{align}

그러나 분수가 포함되어 있으면 다음과 같이 보입니다.

예: 분수가 포함된 증대 행렬

암호:

\begin{align} 
    \begin{gmatrix}[p] 
        1 & 2 & \frac{1}{3} & \mline & 40 \\
        2 & 3 & \frac{1}{4} & \mline & 500 \\
        3 & 4 & 5 & \mline & \frac{1}{6}
    \end{gmatrix} 
\end{align}

선이 점선으로 표시되어 실제로 작동하지 않습니다. 분수가 거의 닿을 듯한 모습도 미학적으로 보입니다.

당신이 나를 도울 수 있기를 바랍니다.

답변1

수동 수정을 제안해 드릴 수 있습니다.

\documentclass{article}
\usepackage{amsmath}
\usepackage{gauss}

% patch gauss macros for doing their work in `align'
% and other amsmath environments; see
% http://tex.stackexchange.com/questions/146532/
\usepackage{etoolbox}
\makeatletter
\patchcmd\g@matrix
 {\vbox\bgroup}
 {\vbox\bgroup\normalbaselines}% restore the standard baselineskip
 {}{}
\makeatother


\newcommand{\mline}[1][0pt]{%
  \hspace{-\arraycolsep}%
  \ifdim#1>0pt
    \dimen0=\ht\strutbox \dimen2=\dimen0
    \advance\dimen0 #1\relax
    \ht\strutbox=\dimen0
  \fi
  \smash{\strut\vrule} % the `\vrule` is as high and deep as a strut
  % since assignments to \ht\strutbox are global, we restore the height
  \ifdim#1>0pt
    \ht\strutbox=\dimen2
  \fi
  \hspace{-\arraycolsep}%
}

\begin{document}
\[
\begin{gmatrix}[p]
1 & 2 & \mline & 3 \\
4 & 5 & \mline & 6 \\
7 & 8 & \mline[2pt] & \frac{1}{6}
\rowops
 \swap{0}{1}
 \mult{0}{\cdot 7}
 \add[5]{1}{2}
\end{gmatrix}
\]
\end{document}

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

분수가 충돌하는 경우 새 \gfrac매크로를 사용하세요.

\documentclass{article}
\usepackage{amsmath}
\usepackage{gauss}

% patch gauss macros for doing their work in `align'
% and other amsmath environments; see
% http://tex.stackexchange.com/questions/146532/
\usepackage{etoolbox}
\makeatletter
\patchcmd\g@matrix
 {\vbox\bgroup}
 {\vbox\bgroup\normalbaselines}% restore the standard baselineskip
 {}{}
\makeatother

\newcommand{\gfrac}[2]{\frac{\smash[b]{\mathstrut}#1}{\smash[t]{\mathstrut}#2}}

\newcommand{\BAR}[1][0pt]{%
  \hspace{-\arraycolsep}%
  \ifdim#1>0pt
    \dimen0=\ht\strutbox \dimen2=\dimen0
    \advance\dimen0 #1\relax
    \ht\strutbox=\dimen0
  \fi
  \smash{\strut\vrule} % the `\vrule` is as high and deep as a strut
  % since assignments to \ht\strutbox are global, we restore the height
  \ifdim#1>0pt
    \ht\strutbox=\dimen2
  \fi
  \hspace{-\arraycolsep}%
}

\begin{document}
\[
\begin{gmatrix}[p]
1 & \gfrac{1}{3} & \BAR & 3 \\
4 & \gfrac{1}{4} & \BAR[4pt] & 6 \\
7 & 8 & \BAR[2pt] & \frac{1}{6}
\rowops
 \swap{0}{1}
 \mult{0}{\cdot 7}
 \add[5]{1}{2}
\end{gmatrix}
\]
\end{document}

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

그러나 나의 조언은 분수에 슬래시 형식을 사용하는 것입니다.

답변2

그냥 일반을 사용하십시오 array:

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

\documentclass{article}
\begin{document}
\[
  \left(\begin{array}{@{} r r r | r @{}}
    1 & 2 & 3 & 40 \\
    2 & 3 & 4 & 500 \\
    3 & 4 & 5 & 6000
  \end{array}\right)
  \qquad
  \renewcommand{\arraystretch}{1.2}% http://tex.stackexchange.com/a/31704/5764
  \left(\begin{array}{@{} r r r | r @{}}
    1 & 2 & \frac{1}{3} & 40 \\
    2 & 3 & \frac{1}{4} & 500 \\
    3 & 4 & 5 & \frac{1}{6}
  \end{array}\right)
\]
\end{document}

예, 열 사양을 제공해야 하지만 정렬을 제어할 수 있을 뿐만 아니라 |간격 없이 수직으로 확장되는 기본 열 규칙을 사용할 수도 있습니다.

관련 정보