Text Formattingitemize custom format for optional argument

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
bootcut
Posts: 6
Joined: Fri Mar 02, 2012 6:07 pm

itemize custom format for optional argument

Post by bootcut »

Hello, I feel like there's gotta be a simple way to do this, but I can't figure out how. I want to make a list with various optional arguments, but I want all these optional arguments to be boldfaced. Is there a way I can make the itemize environment boldface all my optional arguments without explicitly bold facing each argument individually? I know enumitem can do a lot with lists, but I can't find if/how it will do this.

Code: Select all

\documentclass{article}
\begin{document}
\begin{itemize}
  \item[{\bf Alice}] text
  \item[{\bf Bob}] text
  \item[{\bf Carl}] text
\end{itemize}
\end{document}
This isn't too annoying unless I have like 50 items in the list... Then a shortcut to make itemize boldface by default would be great! Especially if I then decide I would rather not boldface the items, but italicize them.

Recommended reading 2024:

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

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

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

itemize custom format for optional argument

Post by Stefan Kottwitz »

itemize is for bulleted lists. I recommend to use a description list:

Code: Select all

\documentclass{article}
\begin{document}
\begin{description}
  \item[Alice] text
  \item[Bob] text
  \item[Carl] text
\end{description}
\end{document}
Stefan
LaTeX.org admin
bootcut
Posts: 6
Joined: Fri Mar 02, 2012 6:07 pm

Re: itemize custom format for optional argument

Post by bootcut »

That's what I tried originally, but the alignment isn't what I want. If the arguments are different lengths, it doesn't look right. Can the alignment of description be changed to be similar to itemize?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

itemize custom format for optional argument

Post by Stefan Kottwitz »

Sure - did you read the enumitem manual and tried the options?

Stefan
LaTeX.org admin
bootcut
Posts: 6
Joined: Fri Mar 02, 2012 6:07 pm

itemize custom format for optional argument

Post by bootcut »

Thanks Stefan!
I had to take a long and hard look at the enumitem options again (I really didn't understand some of the options on my first read), but with some additional help from:
http://tex.stackexchange.com/questions/ ... -of-labels
I figured it out. I also had to update enumitem, stupid ubuntu package uses a way old version. Anyway, here's what I ended up with to get what I wanted, also included it using itemize, to show that the alignment is the same for the description and itemize environment.

Code: Select all

\documentclass{article}  
\usepackage{enumitem}  
\SetLabelAlign{parright}{\parbox[t]{\labelwidth}{\raggedleft#1}}
\setlist[description]{align=parright,labelindent=-2cm,labelwidth=!}
\begin{document}
\begin{description}
  \item[Abraham] text text text
  \item[Bob] text
  \item[Charles] text
\end{description}
\begin{itemize}
  \item text
  \item[Abraham] text
\end{itemize}
\end{document}
Post Reply