16

How the following image could be generated in LaTeX? It is an arithmetic progression.

enter image description here

I don't have any idea how to do it. Can you help me?

\documentclass[a4paper, 11pt]{article}

\begin{document}

$$\begin{array}{ccccccc} -1, & 2, & 5, & 8, & 11, & 14, & 17,\ldots \end{array}$$

\end{document}

3 Answers3

19

I suggest you employ \underbracket, a macro provided by the mathtools package.

enter image description here

Speaking for myself, I think this expression would look better without the commas.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{mathtools} % for '\underbracket' command
\newcommand\ub{{\underbracket[0.4pt]{,\quad}_{+3}}}

\begin{document} [ -1\ub 2\ub 5\ub 8\ub 11\ub 14\ub 17,\dots ] \end{document}

Mico
  • 506,678
15

Using \foreach loops from TikZ, you can also make the whole thing automatic. In the following example, I defined a command \arithmeticprogression with four arguments:

  1. (optional) The horizontal unit length of the tikzpicture, defaults to 1cm.
  2. The starting point of the arithmetic progression.
  3. The step in the progression.
  4. The number of numbers that should be written in the progression.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{ext.paths.ortho}
\newcommand*{\APsign}{+}
\newcommand*{\arithmeticprogression}[4][1cm]{%
    \ifnum #3<0
        \renewcommand*{\APsign}{}
    \else
        \renewcommand*{\APsign}{+}
    \fi
    \begin{tikzpicture}[x=#1, every node/.style={inner xsep=0pt, inner ysep=1.5pt, anchor=base}]
        \foreach \x [evaluate=\x as \y using int(#2+(\x-1)*#3)] in {1, ..., #4}
            \node (\x) at (\x, 0) {$\y$\makebox[0pt][l]{,}};
        \foreach \x [evaluate=\x as \z using int(\x-1)] in {2, ..., #4}
            \draw[teal] (\z.south east) |-|[distance=-3pt] (\x.south west) node[midway, below, black] {$\APsign#3$};
        \node at ($(#4,0)+(1,0)$) {$\dots$};
    \end{tikzpicture}
}
\begin{document}
\arithmeticprogression{-1}{3}{7}

\arithmeticprogression{2}{4}{4}

\arithmeticprogression{1}{-2}{6} \end{document}

Vincent
  • 20,157
8

A non-conventional use of tabularray:

\documentclass[a4paper, 11pt]{article}
\usepackage{xcolor}
\usepackage{tabularray}

\begin{document} [ \begin{tblr}{ colspec={*{15}{c}}, columns={colsep=1pt}, row{1,2}={rowsep=-4pt}, row{3}={rowsep=2pt}, cell{3}{even}={preto={+3}}, hline{3}={even}{blue,wd=2pt}, vline{2-Y}={2}{blue,wd=2pt} } -1, && 2, && 5, && 8, && 11, && 14, && 17,&&\ldots\ &&&&&&&&&&&&&&\ &&&&&&&&&&&&&&\ \end{tblr} ] \end{document}

enter image description here

CarLaTeX
  • 62,716