Text FormattingAdd A Symbol Or Box To The Enumerate Counter

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
kurttodoroff
Posts: 27
Joined: Thu Feb 07, 2019 4:25 pm

Add A Symbol Or Box To The Enumerate Counter

Post by kurttodoroff »

I want to use the Enumerate list environment for 500 items (that will appear in multiple columns, using the multicol package), formatted as follows:
Screen Shot 2019-03-18 at 20.44.59.jpg
Screen Shot 2019-03-18 at 20.44.59.jpg (17.96 KiB) Viewed 4194 times
I want the enumerated list item number to appear in the center of the rounded corner rectangle (vertically and horizontally). I want all rectangles to be the same width, whether the value is 1 (not 001) or 500. I want the rounded corner rectangle to be centered, vertically, on the data that follows it. (This is not the case, in my attachment.)

I have researched a method (with and without the enumitem package) to modify the enumerate counter to appear on top of a symbol or box that resembles the rounded corner rectangle that I want to use. I have not found a solution.

Thank you.

Kurt Todoroff

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Add A Symbol Or Box To The Enumerate Counter

Post by Stefan Kottwitz »

Hi Kurt!

Here is a way to display numbers in such a format:

Code: Select all

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\newcommand*\rect[1]{\tikz[baseline=(char.base)]{
            \node[shape=rounded rectangle, draw,
            inner sep=2pt, minimum width=3em,
            fill=blue, text=white, font=\sffamily\bfseries] (char) {#1};}}
\begin{document}
Test:  \rect{1} \rect{20} \rect{500} baseline aligned.
\end{document}
numbers.png
numbers.png (8.87 KiB) Viewed 4183 times
Stefan
LaTeX.org admin
kurttodoroff
Posts: 27
Joined: Thu Feb 07, 2019 4:25 pm

Add A Symbol Or Box To The Enumerate Counter

Post by kurttodoroff »

Hi, Stefan.

You have produced a fine piece of work. My gratitude.

I modified your work, and, I used it to obtain the results that I want.

\newcommand*\rect[1]{\tikz[baseline=(char.base)]{
\node[shape=rounded rectangle, draw,
inner sep=4pt, minimum width=3em,
fill=black, text=white, font=\bfseries] (char) {#1};}}
\newcommand*\rectitem{%
\stepcounter{enumi}\item[\rect{\theenumi}]}
Screen Shot 2019-03-19 at 12.31.43.jpg
Screen Shot 2019-03-19 at 12.31.43.jpg (39.18 KiB) Viewed 4173 times
How can I alter the box geometry to make it resemble a rectangle, that uses small radius corners, instead of using semi-circles at the left and right sides?

Thank you.

Kurt
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Add A Symbol Or Box To The Enumerate Counter

Post by Stefan Kottwitz »

Hi,

you can change to rectangle with rounded corners and a value, less maximum width:

\node[shape=rectangle, draw, inner sep=4pt, minimum width=2em,
fill=black, text=white, font=\bfseries, rounded corners = 4]


Stefan
LaTeX.org admin
kurttodoroff
Posts: 27
Joined: Thu Feb 07, 2019 4:25 pm

Add A Symbol Or Box To The Enumerate Counter

Post by kurttodoroff »

Hi, Stefan.

I made a couple of tweaks, and, I am very pleased with the results.
Screen Shot 2019-03-20 at 20.57.19.jpg
Screen Shot 2019-03-20 at 20.57.19.jpg (25.35 KiB) Viewed 4140 times
Again, my gratitude.

Regards,

Kurt
Post Reply