1

I'm doing a beamer presentation and defined some custom itemize bullets, which look like this:

\newcommand{\pro}{\item[\textbf{\color{green}+}]}
\newcommand{\con}{\item[\hspace{-2ex}\textbf{\color{red}--}]}

They work very well, but are not centered under eachother, the \con sign is more indented than the \pro sign.

I tried

\begin{itemize}[align=center]

with no effect.

Is there a way without using enumitem (which isn't quite compatible to beamer) to align the customized bullets in a centered position?

Maybe it's also possible with enumitem and I haven't found the right way to implement it yet?

Knigge46
  • 171

2 Answers2

3

You can have what you want with mathtools and its \(math)clap command.

I defined differently your custom bullets, in math mode. Note the endash has not the same width as the + character.

\documentclass{beamer}
\usepackage{mathtools}

\newcommand{\pro}{\item[\boldmath$\mathclap{\color{green}+}$ ]}
\newcommand{\con}{\item[\boldmath$ \mathclap{\color{red}-}$ ]}

\begin{document}

\begin{frame}
  \begin{itemize}
    \pro item1 
    \con item2
  \end{itemize}
\end{frame}

\end{document} 

Note: If the symbols that you want to use all have the same width, the mathclap command is not necessary.

enter image description here

Bernard
  • 271,350
  • Is \mathclap necessary? In math mode plus and minus have the same width in most fonts. – egreg Nov 29 '15 at 15:54
  • It was just in case. Actually, I initially retained the endash and it then was necessary. Furthermore, I'm not sure, these are the only symbols the O?P. wants to use. I'll add some explanations about this. – Bernard Nov 29 '15 at 16:17
  • The $\boldmath$ solution didn't come to my mind, that one does the job very well! :) And as @egreg said, if you only use + and -, you won't need the \mathclap. But for further use, I'll keep that in mind. – Knigge46 Dec 01 '15 at 09:19
  • Can this be generalized somehow so that mixing \item with \item[\customSymbol] works correctly? Default bullets are right-aligned (as if in \llap) and wider custom symbols stick out on the left. – eudoxos Apr 11 '16 at 06:48
  • @eudoxos: It seems that with beamer and just the above code, everything is centred (I've just tested with a custom ++ label). Could you post a minimal example demonstrating the problem? – Bernard Apr 11 '16 at 08:30
  • @Bernard: Can't add images to comments: http://i.imgur.com/aQQdnhN.png . The example wide symbol is \StopWatchEnd from ifsym package used first with \item[\StopWatchEnd] and second with \item[\clap{\StopWatchEnd}]. \clap centers around the tip of arrow-shaped default bullets and the symbol then sticks out to the right (I wrote left before, sorry). – eudoxos Apr 11 '16 at 09:47
0

Since the + is larger than --, I centered the -- in the same space. This was complicated by the fact that -- is slightly assymetrical as demonstrated in the \fbox demos, and of course beamer redefining everything.

\documentclass{beamer}

\newlength{\tempdima}

\newcommand{\pro}{\item[\color{green}\textbf{+}]}
\newcommand{\con}{\item[\settowidth{\tempdima}{\textbf{+}}%
  \hbox to \tempdima{\hfill\hspace{.07ex}\color{red}\textbf{--}\hfill}]}

\begin{document}

\begin{frame}
  \begin{itemize}
    \pro item1
    \con item2
  \end{itemize}
\fboxsep=0pt
\fbox{\textbf{--}}
{\Huge\fbox{\hspace{.07ex}\textbf{--}}}
{\tiny\fbox{\hspace{.07ex}\textbf{--}}}
\end{frame}

\end{document}

+ and --

John Kormylo
  • 79,712
  • 3
  • 50
  • 120