我想申请鲁菲尼规则但由于我使用了分数,所以看起来拥挤又混乱。有没有办法在行间留出更多空间?
\begin{equation*}
\begin{array}{c|c c c|c}
&1 &-2 &1 &-\frac{4}{27}\\
\frac{1}{3} & &\frac{1}{3} &-\frac{5}{9} &\frac{4}{27}\\
\hline
& 1 &-\frac{5}{3} &\frac{4}{9} &0\\
\end{array}
\end{equation*}
答案1
软件包的解决方案是cellspace
,在以字母为前缀的说明符的列中S
(或者C
如果您加载siunitx
),在单元格的顶部和底部添加最小填充。我还加载了nccmath
中等大小的分数,从我的角度来看,在这种情况下看起来更好:
\documentclass[a4paper,12pt]{article}
\usepackage{cellspace}
\setlength{\cellspacetoplimit}{4pt}
\setlength{\cellspacebottomlimit}{4pt}
\usepackage{amsmath, nccmath}
\begin{document}
\[ \begin{array}{>{$}Sr<{$}|*{3}{>{$}Sr<{$}}|>{$}Sr<{$}}
&1 &-2 &1 &-\mfrac{4}{27} \\
\mfrac{1}{3} & &\mfrac{1}{3} &-\mfrac{5}{9} &\mfrac{4}{27} \\
\hline
& 1 &-\mfrac{5}{3} &\mfrac{4}{9} & 0
\end{array} \]
\end{document}
答案2
我的解决方案的一个变体表格 Ruffini-Horner 算法的命令
\ruffini
当你必须容纳较大的物体时,可选参数设置单元格的间隙
\documentclass{article}
\usepackage{xparse,array,makecell}
\ExplSyntaxOn
\NewDocumentCommand{\ruffini}{O{0pt}mmmm}
{% #1 = gape, #2 = polynomial, #3 = divisor, #4 = middle row, #5 = result
\franklin_ruffini:nnnnn { #2 } { #3 } { #4 } { #5 } { #1 }
}
\seq_new:N \l_franklin_temp_seq
\tl_new:N \l_franklin_scheme_tl
\int_new:N \l_franklin_degree_int
\cs_new_protected:Npn \franklin_ruffini:nnnnn #1 #2 #3 #4 #5
{
\group_begin:
\makegapedcells
\setcellgapes{#5}
% Start the first row
\tl_set:Nn \l_franklin_scheme_tl { & }
% Split the list of coefficients
\seq_set_split:Nnn \l_franklin_temp_seq { , } { #1 }
% Remember the number of columns
\int_set:Nn \l_franklin_degree_int { \seq_count:N \l_franklin_temp_seq }
% Fill the first row
\tl_put_right:Nx \l_franklin_scheme_tl
{ \seq_use:Nn \l_franklin_temp_seq { & } }
% End the first row and leave two empty places in the next
\tl_put_right:Nn \l_franklin_scheme_tl { \\ #2 & & }
% Split the list of coefficients and fill the second row
\seq_set_split:Nnn \l_franklin_temp_seq { , } { #3 }
\tl_put_right:Nx \l_franklin_scheme_tl
{ \seq_use:Nn \l_franklin_temp_seq { & } }
% End the second row
\tl_put_right:Nn \l_franklin_scheme_tl { \\ \hline }
% Split and fill the third row
\seq_set_split:Nnn \l_franklin_temp_seq { , } { #4 }
\tl_put_right:Nx \l_franklin_scheme_tl
{ & \seq_use:Nn \l_franklin_temp_seq { & } }
% Start the array (with \use:x because the array package
% doesn't expand the argument)
\use:x
{
\exp_not:n { \begin{array} } { r | *{\int_eval:n { \l_franklin_degree_int - 1 }} { r } | r }
}
% Body of the array and finish
\tl_use:N \l_franklin_scheme_tl
\end{array}
\group_end:
}
\ExplSyntaxOff
\begin{document}
\[
\ruffini[2pt]{1,-2,1,-\frac{4}{27}}
{\frac{1}{3}}
{\frac{1}{3},-\frac{5}{9},\frac{4}{27}}
{1,-\frac{5}{3},\frac{4}{9},0}
\qquad
\ruffini{1,-6,11,-6}{2}{2,-8,6}{1,-4,3,0}
\]
\end{document}
答案3
使用makecell
:
\documentclass[a4paper,12pt]{article}
\usepackage{makecell}
\usepackage{nccmath}
\begin{document}
\[\setcellgapes{3pt}
\makegapedcells
\begin{array}{r|*{3}{r}|r}
& 1 & -2 & 1 & -\mfrac{4}{27} \\
\mfrac{1}{3} & & \mfrac{1}{3} & -\mfrac{5}{9} & \mfrac{4}{27} \\
\hline
& 1 & -\mfrac{5}{3} & \mfrac{4}{9} & 0
\end{array}
\]
\end{document}