0

I have written the following code:

\documentclass[a4paper,twoside,12pt]{article}
\usepackage[margin=1cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{sansmathfonts}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[T1]{fontenc}
\usepackage{ragged2e}
\usepackage{amsthm,amsfonts,amssymb,fge,mathtools}
\usepackage{parskip}

\usepackage{tabstackengine}
\setstackEOL{\cr}
\setstacktabbedgap{2pt}
\setstackgap{L}{8pt}

\pagestyle{empty}

\author{}
\date{}
\title{}

\begin{document}

$\boxed{\Matrixstack{\bullet & \bullet & \bullet & \bullet \cr \bullet & \bullet & \bullet & \bullet \cr \bullet & \bullet & \bullet & \bullet \cr \bullet & \bullet & \bullet & \bullet \cr \bullet & \bullet & \bullet & \bullet}}$

\end{document}

which gives the following output:

enter image description here

but I don’t want that extra vertical space between the box and the bullets. How can I remove it?

3
  • 2
    Please note: This is not a do it for me site. So you should at least show, what you've already tried and where you failed. For such simple boxes and bullets you could simply use \framebox, \bullet and an array inside a math environment. Or you can use the native picture environment. Or you can use TikZ. Or you can use pstricks. …
    – cabohah
    Commented Sep 14, 2023 at 9:36
  • 1
    There are several ways to do it, like A) using Tikz (pretty straight forward), B) using \fbox, \raisebox and wingding font, C) certainly you can use tables as well.
    – MS-SPO
    Commented Sep 14, 2023 at 10:02
  • @cabohah I have edited my question according to your (fair) comment. I’d really like for it to be re-opened.
    – Federico
    Commented Sep 14, 2023 at 14:41

3 Answers 3

1

It's easier than you think.

\documentclass{article}

\ExplSyntaxOn

\NewDocumentCommand{\scatola}{mm}
 {% #1 = number of rows, #2 = number of columns
  \group_begin:
  \setlength{\fboxsep}{0pt}
  \fbox{$\federico_scatola:nn { #1 } { #2 }$}
  \group_end:
 }

\cs_new_protected:Nn \federico_scatola:nn
 {
  \begin{array}{*{#2}{c}}
  \prg_replicate:nn { #1 } { \bullet \prg_replicate:nn { #2 - 1 } { & \bullet } \\ }
  \end{array}
 }

\ExplSyntaxOff

\begin{document}

$\scatola{1}{5}\times\scatola{1}{4} = \scatola{5}{4}$

\end{document}

enter image description here

I add here the picture you wanted to reproduce in the original version of the question.

enter image description here

1
  • Thank you so much @egreg.
    – Federico
    Commented Sep 15, 2023 at 3:31
5

For example with OpTeX:

\def\bbullets #1x#2 {%
   \frame{\vbox{\fornum 1..#2\do{\hbox{\fornum 1..#1\do{\mybullet}}}}}
}
\def\mybullet{\strut\kern.3em$\bullet$\kern.3em}

% test:
\bbullets 3x4

\bye
1
  • Thank you @wipet, but I’m not using optex unfortunately
    – Federico
    Commented Sep 14, 2023 at 16:17
3

Try this simple format:

\documentclass{book}
\usepackage{mathtools}

\begin{document}

\newcommand{\fourbullets}{\bullet &\bullet &\bullet &\bullet}%
\newcommand{\fivebullets}{\bullet &\bullet &\bullet &\bullet &\bullet}%

$
\fbox{$\begin{array}{ccccc}
\fivebullets
\end{array}
$}
\times
\fbox{$
\begin{array}{ccccc}
\fourbullets
\end{array}$
}=
\fbox{$
\begin{array}{ccccc}
\fivebullets\\
\fivebullets\\
\fivebullets\\
\fivebullets\\
\fivebullets
\end{array}$
}
$
\end{document}

enter image description here

But wipet already gave a best automated suggestion.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .