标题说明了一切。由于我是新手,我不知道该怎么做。
有什么帮助吗?
答案1
如果您考虑在重复的小数组上使用水平线,则可以使用以下命令\overline
:
\documentclass{article}
\begin{document}
$\frac{1}{7}=0.\overline{142857}$
\end{document}
答案2
至少有四种表示方法;下面是生成所有方法的方法,请随意选择(当然可以修改宏名称)。我强烈建议使用特殊的宏名称,即使您决定使用上划线,这样您以后可以改变主意并选择另一种实现。
\documentclass{article}
\ExplSyntaxOn
%% Dots on the first and last digit
\NewDocumentCommand{\periodfl}{m}
{
\repdec_initial_final_dots:n { #1 }
}
\cs_new_protected:Npn \repdec_initial_final_dots:n #1
{
\tl_if_single:nTF { #1 }
{ \dot{#1} } % just one digit
{
\dot{\tl_range:nnn { #1 } { 1 } { 1 } } % first digit
\tl_range:nnn { #1 } { 2 } { -2 } % middle digits
\dot{\tl_range:nnn { #1 } { -1 } { -1 } } % last digit
}
}
%% Dots on all digits
\NewDocumentCommand{\periodalldots}{m}
{
\repdec_initial_all_dots:n { #1 }
}
\cs_new_protected:Npn \repdec_initial_all_dots:n #1
{
\tl_map_inline:nn { #1 } { \dot{##1} }
}
%% Bar over period
\NewDocumentCommand{\periodbar}{m}
{
\overline{ #1 }
}
%% Parentheses around period
\NewDocumentCommand{\periodparens}{m}
{
(#1)
}
%% Dot on unique digit, bar on several digits
\NewDocumentCommand{\periodmixed}{m}
{
\repdec_mixed:n { #1 }
}
\cs_new_protected:Npn \repdec_mixed:n #1
{
\int_case:nnF { \tl_count:n { #1 } }
{
{ 0 } { }
{ 1 } { \dot{#1} }
}
{
\overline{#1}
}
}
\ExplSyntaxOff
\begin{document}
$1.2\periodfl{3}$ --- $1.2\periodfl{34}$ --- $1.2\periodfl{345}$ ---
$1.2\periodfl{3456}$ --- $1.2\periodfl{34567}$
\medskip
$1.2\periodalldots{3}$ --- $1.2\periodalldots{34}$ --- $1.2\periodalldots{345}$ ---
$1.2\periodalldots{3456}$ --- $1.2\periodalldots{34567}$
\medskip
$1.2\periodbar{3}$ --- $1.2\periodbar{34}$ --- $1.2\periodbar{345}$ ---
$1.2\periodbar{3456}$ --- $1.2\periodbar{34567}$
\medskip
$1.2\periodparens{3}$ --- $1.2\periodparens{34}$ --- $1.2\periodparens{345}$ ---
$1.2\periodparens{3456}$ --- $1.2\periodparens{34567}$
\medskip
$1.2\periodmixed{3}$ --- $1.2\periodmixed{34}$ --- $1.2\periodmixed{345}$ ---
$1.2\periodmixed{3456}$ --- $1.2\periodmixed{34567}$
\end{document}
答案3
为了完整起见,这里是在传统 TeX 编程中该宏的一种可能方法:
\def\afterfi#1#2\fi{\fi#1}
\def\periodfl#1{\pflA#1.}
\def\pflA#1#2{\dot#1\ifx.#2\else\afterfi{\pflB#2}\fi}
\def\pflB#1#2{\ifx.#2\dot#1\else#1\afterfi{\pflB#2}\fi}
\def\periodalldots#1{\padotsA#1.}
\def\padotsA#1#2{\dot#1\ifx.#2\else\afterfi{\padotsA#2}\fi}
\let\periodbar=\overline
\def\periodparens#1{(#1)}
\def\periodmixed#1{\pmiA#1.}
\def\pmiA#1#2{\ifx.#2\dot#1\else\afterfi{\pmiB#1#2}\fi}
\def\pmiB#1.{\overline{#1}}
$1.2\periodfl{3}$ --- $1.2\periodfl{34}$ --- $1.2\periodfl{345}$ ---
$1.2\periodfl{3456}$ --- $1.2\periodfl{34567}$
\medskip
$1.2\periodalldots{3}$ --- $1.2\periodalldots{34}$ --- $1.2\periodalldots{345}$ ---
$1.2\periodalldots{3456}$ --- $1.2\periodalldots{34567}$
\medskip
$1.2\periodbar{3}$ --- $1.2\periodbar{34}$ --- $1.2\periodbar{345}$ ---
$1.2\periodbar{3456}$ --- $1.2\periodbar{34567}$
\medskip
$1.2\periodparens{3}$ --- $1.2\periodparens{34}$ --- $1.2\periodparens{345}$ ---
$1.2\periodparens{3456}$ --- $1.2\periodparens{34567}$
\medskip
$1.2\periodmixed{3}$ --- $1.2\periodmixed{34}$ --- $1.2\periodmixed{345}$ ---
$1.2\periodmixed{3456}$ --- $1.2\periodmixed{34567}$
\bye
答案4
这些答案都很友善,但你们把事情复杂化了,实际上根本不需要\.{your number}
使用任何包,它是内置的。或其他口音,请参阅https://en.wikibooks.org/wiki/LaTeX/Special_Characters