LaTeX forum ⇒ Text FormattingAdd A Symbol Or Box To The Enumerate Counter Topic is solved

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

Add A Symbol Or Box To The Enumerate Counter

Postby kurttodoroff » Tue Mar 19, 2019 3:03 am

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 153 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

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

Postby Stefan Kottwitz » Tue Mar 19, 2019 11:40 am

Hi Kurt!

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

  1. \documentclass{article}
  2. \usepackage{tikz}
  3. \usetikzlibrary{shapes}
  4. \newcommand*\rect[1]{\tikz[baseline=(char.base)]{
  5. \node[shape=rounded rectangle, draw,
  6. inner sep=2pt, minimum width=3em,
  7. fill=blue, text=white, font=\sffamily\bfseries] (char) {#1};}}
  8. \begin{document}
  9. Test: \rect{1} \rect{20} \rect{500} baseline aligned.
  10. \end{document}


numbers.png
numbers.png (8.87 KiB) Viewed 142 times


Stefan
Site admin

kurttodoroff
Posts: 12
Joined: Thu Feb 07, 2019 4:25 pm

Postby kurttodoroff » Tue Mar 19, 2019 6:36 pm

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 132 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: 9366
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Wed Mar 20, 2019 10:12 pm

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
Site admin

kurttodoroff
Posts: 12
Joined: Thu Feb 07, 2019 4:25 pm

Postby kurttodoroff » Thu Mar 21, 2019 2:59 am

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 99 times


Again, my gratitude.

Regards,

Kurt


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 6 guests