
私は次の方程式を LaTeX で再現しようとしています (回帰出力から):
tabular
とを使ってみましたalign
が、まだ同じような見た目にできません。具体的には、括弧内の数量が係数の真下にあったり、小数点の位置が揃っていなかったりします。これを実現する方法について何かヒントはありますか?
編集: 私の試みを MWE として含めようと思いました:
\documentclass{article}
\usepackage{amsmath}
\newcommand{\ti}[1]{\textit{#1}}
\begin{document}
\begin{alignat*}{9}
\widehat{\ti{math}4} & = 24.49 & {} - .274 & \ti{pctsgle} & {} - .422 & \ti{free} & {} - .752 & \ti{lmedinc} & {} + 9.01 & \ti{lexppp} \\
& \phantom{{} = {}} (59.24) & (.161) & & (.071) & & (5.358) & & (4.04) \\
n & = 299, R^2 = .472
\end{alignat*}
\end{document}
答え1
.を使用すると、array
数値の表記が若干変わります (以前は小数点は常に数値でした)。
\documentclass{article}
\usepackage{geometry}
\usepackage{amsmath}
\usepackage{mathabx} % for widehat
\newcommand{\ti}[1]{\textit{#1}}
\usepackage{siunitx}
\begin{document}
\[\setlength\arraycolsep{2pt}
\sisetup{input-symbols = {( )}}
\begin{array}{r c
S[table-format=2.2] c
S[table-format=1.3]l c
S[table-format=1.3]l c
S[table-format=1.3]l c
S[table-format=1.2]l
}
\widehat{\ti{math}4}
& =
& 24.49 & - & 0.274 & \ti{pctsgle} & -
& 0.422 & \ti{free} & -
& 0.752 & \ti{lmedinc} & +
& 9.01 & \ti{lexppp} \\
&
& (59.24) & & (0.161) & &
& (0.071) & &
& (5.358) & &
& (4.04) & \\
n & = & \multicolumn{13}{l}{299,\quad R^2 = 0.472}
\end{array}
\]
\end{document}
答え2
下の数字は小さく印刷するので、近くの数字と同じクラスになる可能性は低くなります。 を使用すると、\hidewidth
それらの数字が水平方向のスペースを占有せず、メインの係数の下に中央に配置されます。
\documentclass{article}
\usepackage{amsmath,amssymb}
\newcommand{\tvar}[1]{\operatorname{\mathit{#1}}}
\newcommand{\coeff}[2]{%
\begingroup\renewcommand{\arraystretch}{0.75}%
\begin{array}[t]{@{}c@{}}
#1 \\ % the main number
\scriptstyle \hidewidth(#2)\hidewidth
\end{array}%
\endgroup
}
\begin{document}
\begin{align*}
\widehat{\tvar{math}4}
& = \coeff{24.49}{59.24}
- \coeff{.274}{.161} \tvar{pctsgle}
- \coeff{.422}{.071} \tvar{free}
- \coeff{.752}{5.538} \tvar{lmedinc}
+ \coeff{9.01}{4.04} \tvar{lexppp}
\\
n & = 299,\quad R^2 = .472
\end{align*}
\end{document}