Text Formatting ⇒ Add A Symbol Or Box To The Enumerate Counter
-
- Posts: 27
- Joined: Thu Feb 07, 2019 4:25 pm
Add A Symbol Or Box To The Enumerate Counter
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
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
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}
-
- Posts: 27
- Joined: Thu Feb 07, 2019 4:25 pm
Add A Symbol Or Box To The Enumerate Counter
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}]}
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
- Stefan Kottwitz
- Site Admin
- Posts: 10335
- Joined: Mon Mar 10, 2008 9:44 pm
Add A Symbol Or Box To The Enumerate Counter
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
-
- Posts: 27
- Joined: Thu Feb 07, 2019 4:25 pm
Add A Symbol Or Box To The Enumerate Counter
I made a couple of tweaks, and, I am very pleased with the results.
Again, my gratitude.
Regards,
Kurt