7

I created the following table. however, the bullets are not aligned. What can I do to get them aligned?

\documentclass{beamer}
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\newcommand{\tabitem}{~~\llap{\textbullet}~~}
\begin{document}

\begin{frame}{Symbolic Math Toolbox}
\begin{itemize}
\item Don't do nasty calculations by hand!
\item Symbolics vs. Numerics
\end{itemize}
\begin{tabular}{| p{1.3cm} | p{4cm} | p{4cm} |} \hline    & \textcolor{green}{Advantages} & \textcolor{red}{Disadvantages} \\ \hline
Symbolic & \tabitem Analytical solutions & \tabitem Sometimes can't be solved \\
 & \tabitem Lets you intuit things about solution form & \tabitem Can be overly complicated \\ \hline 
Numeric & \tabitem Always get a solution & \tabitem Hard to extract a deep understanding \\
 &\tabitem Can make solutions accurate & \tabitem Num. methods sometimes fail \\  
 & \tabitem Easy to code & \tabitem Can take a while to compute \\  \hline
 \end{tabular}
\end{frame}
\end{document}

enter image description here

5

use

\newcommand\tabitem{\makebox[1em][r]{\textbullet~}}
5

This answer is similar in spirit to the one by @daleif. The difference is that I use the macro \RaggedRight (from the ragged2e package) instead of the basic \raggedright directive; the difference is that \RaggedRight permits hyphenation. I also use a \newcolumntype instruction to set up a new column type called "P" that sets in contents automatically in Ragged-Right paragraph mode.

enter image description here

\documentclass{beamer}
\usepackage{booktabs,array,ragged2e}
\newcolumntype{P}[1]{>{\RaggedRight\arraybackslash}p{#1}}
\newcommand{\tabitem}{\textbullet~~}
\begin{document}

\begin{frame}{Symbolic Math Toolbox}
\begin{itemize}
\item Don't do nasty calculations by hand!
\item Symbolics vs.\ Numerics
\end{itemize}
\begin{tabular}{| p{1.4cm} | P{4cm} | P{4cm} |} \hline    
& \textcolor{green}{Advantages} 
& \textcolor{red}{Disadvantages} \\ \hline
Symbolic 
& \tabitem Analytical solutions 
& \tabitem Sometimes can't be solved \\
& \tabitem Lets you intuit things about solution form 
& \tabitem Can be overly complicated \\ \hline 
Numeric 
& \tabitem Always get a solution 
& \tabitem Hard to extract a deep understanding \\
& \tabitem Can make solutions accurate 
& \tabitem Num.\ methods sometimes fail \\  
& \tabitem Easy to code 
& \tabitem Can take a while to compute \\  \hline
\end{tabular}
\end{frame}
\end{document}
  • Yes, that is a better solution – daleif Jul 28 '15 at 14:17
3

Presumably because ~ is stretchable and your columns are attempting to to keep a straight right edge.

Probably better to use

\documentclass{beamer}
\usepackage{booktabs,array}% http://ctan.org/pkg/booktabs
\newcommand{\tabitem}{~~\llap{\textbullet}~~}
\begin{document}

\begin{frame}{Symbolic Math Toolbox}
\begin{itemize}
\item Don't do nasty calculations by hand!
\item Symbolics vs. Numerics
\end{itemize}
\begin{tabular}{| >{\raggedright}p{1.3cm} | >{\raggedright}p{4cm} | 
    >{\raggedright\arraybackslash}p{4cm} |} \hline &
  \textcolor{green}{Advantages} & \textcolor{red}{Disadvantages}
  \\
  \hline Symbolic & \tabitem Analytical solutions & \tabitem Sometimes
  can't be solved
  \\
  & \tabitem Lets you intuit things about solution form & \tabitem Can
  be overly complicated
  \\
  \hline Numeric & \tabitem Always get a solution & \tabitem Hard to
  extract a deep understanding
  \\
  & \tabitem Can make solutions accurate & \tabitem Num. methods
  sometimes fail
  \\
  & \tabitem Easy to code & \tabitem Can take a while to compute
  \\
  \hline
\end{tabular}
\end{frame}
\end{document}

and thus setting the cols ragged right. Note the \arraybackslash added to the last column.

  • BTW: Micos solution using \RaggedRight is probably better – daleif Jul 29 '15 at 7:13
0

Here is another solution with a tabitem environment, which actually is an itemize environment and so also takes care of the indention after a linebreak.

Unfortunately it seems that the array packages causes a spurious extra line at the end of the tabitem environment, so I haven't loaded this package and therefore also not the ragged2e package.

I want to point out that the definiton of this environment is not from me. I think I have it almost 10 years now, but cannot remember where I grabbed it from. I somebody knows, please raise the hand and I will add the source here.

\documentclass{beamer}
%\usepackage{array}
%\usepackage{ragged2e}
%    \newcolumntype{P}[1]{>{\RaggedRight\arraybackslash}p{#1}}
\usepackage{paralist}
\usepackage{booktabs}
    \newenvironment{tabitem}{%
        \vspace*{-0.5\baselineskip}%
        \setdefaultitem{\normalfont\bfseries\textbullet}%
            {\normalfont\bfseries\textendash}{}{}%
        \setdefaultleftmargin{1.1em}{1.1em}{}{}{}{}%
        \begin{compactitem}%
    }{%
        \end{compactitem}%
        \vspace*{-\baselineskip}%
    }
\begin{document}
\begin{frame}{Symbolic Math Toolbox}
\begin{itemize}
\item Don't do nasty calculations by hand!
\item Symbolics vs.\ Numerics
\end{itemize}
%% use me when using `array' and `ragged2e'
%% but unfortunately this creates a spurious blank line after the `tabitem'
%% environment
%\begin{tabular}{p{1.5cm}*{2}{P{4cm}}}
%
% therefore here the solution without these packages
\begin{tabular}{p{1.5cm}*{2}{p{4cm}}}
        \toprule
             & \textcolor{green}{Advantages}
             & \textcolor{red}{Disadvantages}                        \\
        \midrule
    Symbolic & \begin{tabitem}
                   \item Analytical solutions
                   \item Lets you intuit things about solution form
               \end{tabitem}
             & \begin{tabitem}
                   \item Sometimes can't be solved
                   \item Can be overly complicated
               \end{tabitem}                                         \\
        \midrule
    Numeric  & \begin{tabitem}
                   \item Always get a solution
                   \item Can make solutions accurate
                   \item Easy to code
               \end{tabitem}
             & \begin{tabitem}
                   \item Hard to extract a deep understanding
                   \item Num.\ methods sometimes fail
                   \item Can take a while to compute
               \end{tabitem}                                         \\
        \bottomrule
\end{tabular}
\end{frame}
\end{document}

image showing the result of above code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.