1

I want to create sort of repetitive pattern in an A4 page with minimal margin. As a sample image, given with this text. enter image description here

But I am not getting how to do this. Any hint is appreciable.

3
  • Welcome to TSE. What did you try? Commented Mar 9, 2023 at 11:33
  • Refer the tcolorbox documentation, and refer page number 309 Commented Mar 9, 2023 at 11:56
  • 2
    Can you find a more descriptive title for your post rather then using "How can I make [this]?" Commented Mar 10, 2023 at 5:36

3 Answers 3

6

I would employ tikz with two \foreach loops. Here's the example:

\documentclass{article} \usepackage[margin=0.5in, noheadfoot, nomarginpar]{geometry} \usepackage{tikz} \usepackage{showframe} \renewcommand*\ShowFrameLinethickness{0.2pt} \renewcommand*\ShowFrameColor{\color{blue}} \tikzset{ every node/.style = { draw, red, text = black, font = \large, line width = 1.6pt, rounded corners, minimum width = 3cm, minimum height = 1cm, } } \pagestyle{empty} \begin{document} \begin{figure} \centering \begin{tikzpicture} \foreach \y [evaluate=\y as \yo using \y*1.25] in {0,...,19} { \foreach \x [evaluate=\x as \xo using \x*3.75, evaluate=\d using int(\x+5*\y+1)] in {0,...,4} { \node at (\xo,-\yo) {The day \d}; }} \end{tikzpicture} \end{figure} \end{document} 

enter image description here


EDIT. Here is a slightly altered code, which now generates paragraphs with rows of nodes, which will continue to the other page if necessary. They are copied inside \foreach so you can change how many rows you need.

A couple of things.
Nodes do not add line breaks nor do they accept \newline, \\ or \par by default, unless you specify text width. I also added small padding with inner xsep and inner ysep.

The horizontal space is stretchable and depends on size of your labels. Vertical space is controlled by \lineskip which is equal to 1pt by default. I changed that to 1em. At this point, I have to make a comment. In this example, content of paragraphs very likely exceed a standard paragraph height, and LaTeX adds a minimum distance stored in \lineskip to avoid overlapping. I exploit this fact and change the min space to 1em. This is almost certainly not going to work in other examples.

\documentclass{article} \usepackage[margin=0.5in, noheadfoot, nomarginpar]{geometry} \usepackage{tikz} \tikzset{ every node/.style = { draw, red, line width = 1.6pt, rounded corners, text = black, font = \large, align = center, text width = 4cm, inner xsep = 3pt, inner ysep = 6pt, } } \newsavebox\textlabel \NewDocumentCommand\TL{s}{% \IfBooleanF{#1}{\hfill}% \begin{tikzpicture}[baseline] \node {% Multiple line sample \par Second line \par Third line }; \end{tikzpicture}} \pagestyle{empty} \begin{document} \setlength\parindent{0pt}% \setlength\lineskip{1em}% % minimum vertical space \foreach \x in {1,...,20} {\par\TL* \TL \TL \TL}; \end{document} 

Note, this can also be sorted with longtable.

5
  • One of an excellent suggestion :-) Commented Mar 9, 2023 at 14:16
  • Thank you. But how to add something bellow to "The day" in the same box? {The day \d \\Another line} is not working Commented Mar 9, 2023 at 18:41
  • And how to continue after 100 in another page Commented Mar 9, 2023 at 18:41
  • @TanmoyPati I have added an update to my answer. The new code should do the job (I hope). Commented Mar 9, 2023 at 23:01
  • 1
    @MadyYuvi Thanks. It was a matter of putting a few commands together. Commented Mar 9, 2023 at 23:01
3

MadyYuvi already pointed you to a suitable package, I'll simply expand on this.

\documentclass{article} \usepackage{multicol,tcolorbox} \newtcolorbox{mybox}{colframe=red,colback=white} \begin{document} \begin{multicols}{3} \begin{mybox}The Day 1\end{mybox} \begin{mybox}The Day 1\end{mybox} \begin{mybox}The Day 1\end{mybox} \begin{mybox}The Day 1\end{mybox} \begin{mybox}The Day 1\end{mybox} \begin{mybox}The Day 1\end{mybox} % I think you can imagine how to go on... \end{multicols} \end{document} 

enter image description here

Edit: Advancing the number.

As requested in a comment, you can advance the number displayed in the box. The simplest way is of course to advance the number manually, so

\begin{mybox}The Day 1\end{mybox} \begin{mybox}The Day 2\end{mybox} 

and so on. This is of course not the best way to go.

Then you have the idea of adding a counter which does the numbering for you, see MadyYuvi's answer (+1). This will still require to repeat the code \begin{mybox}The Day \theboxcounter\end{mybox} over and over again.

This is why IMHO the best solution involves a for loop (forloop package):

\documentclass{article} \usepackage{multicol,tcolorbox,forloop} \newtcolorbox{mybox}{colframe=red,colback=white} \begin{document} \begin{multicols}{3} \newcounter{boxcounter} \forloop{boxcounter}{1}{\value{boxcounter} < 25}{% \begin{mybox}The Day \theboxcounter\end{mybox} } \end{multicols} \end{document} 

Result with advancing numbers BTW this answer is completely applicable if you need more than one page of these boxes.

1
  • 1
    It is quite nice and simple. But how to continue with integer? Not 1 at all the boxes Commented Mar 9, 2023 at 18:42
1

Per the OP's comment, just added a counter in @Οὖτις answer,

\documentclass{article} \usepackage{multicol,tcolorbox} \newcounter{boxcounter}% \setcounter{boxcounter}{0}% \renewcommand{\theboxcounter}{\arabic{boxcounter}}% \newtcolorbox{mybox}{code={\refstepcounter{boxcounter}},colframe=red,colback=white} \begin{document} \begin{multicols}{3} \begin{mybox}The Day \theboxcounter\end{mybox} \begin{mybox}The Day \theboxcounter\end{mybox} \begin{mybox}The Day \theboxcounter\end{mybox} \begin{mybox}The Day \theboxcounter\end{mybox} \begin{mybox}The Day \theboxcounter\end{mybox} \begin{mybox}The Day \theboxcounter\end{mybox} % I think you can imagine how to go on... \end{multicols} \end{document} 

enter image description here

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.