Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

By including a tikz-picture in my two (tabular) minipages my items are messed up. Ideally there is a corresponding item for each (except there's an empty entry for the last item in the left table).

Also, how to ensure that the resulting output is horizontally centered in the page, please?

\documentclass{article}
\usepackage{tikz}
\usepackage{soul}
\begin{document}
\newenvironment{Myitemize}{
\renewcommand{\labelitemi}{{}}
\begin{itemize}}{\end{itemize}}

\begin{minipage}[t]{0.5\textwidth}
\begin{tabular}[t]{p{6.5cm}}
\multicolumn{1}{c}{\ul{Discrete}} \\
\begin{enumerate}
  \item Probability mass function (p.m.f.) 
\begin{tikzpicture}
        \draw (0,0)--(5,0);
        \draw (1,2)--(1,0);
        \draw (3,1)--(3,0);
        \draw (4,0.8)--(4,0);
\end{tikzpicture}
    \item $f(x)$ gives $Pr(X=x)$
    \item Zero probability $\Rightarrow$ Impossibility
    \item 
\end{enumerate} \\
\end{tabular}
\end{minipage}
\begin{minipage}[t]{0.5\textwidth}
\begin{tabular}[t]{p{6.5cm}}
\multicolumn{1}{c}{\ul{Continuous}}\\
\begin{Myitemize}
  \item Probability density function (p.d.f.) 
\begin{tikzpicture}
    \draw (0,0)--(5,0);
  \draw (0,.7) ..controls (3,2.5) and (4,.8) ..(5,.7);
\end{tikzpicture}
    \item Not so; $Pr(X=x)=0$ always
    \item Zero probability events do occur
    \item Can get positive probability (area under continuous curve) for intervals no matter how small
\end{Myitemize} \\
\end{tabular}
\end{minipage}




\end{document}
share|improve this question
1  
Why two separate minipages? I think you can get what you want if you just put everything into one tabular environment. –  Paul Gessler Aug 15 at 23:10

1 Answer 1

up vote 6 down vote accepted

As Paul Gessler has commented, you can put every thing in one tabular environment with two p columns each having a width of

>{\raggedright\arraybackslash}p{\dimexpr0.5\textwidth-2\tabcolsep-2\arrayrulewidth\relax} 

minipages are not needed any way. You can further use enumitem package and its resume option to continue numbering. I have also aligned the tikzpictures using the same bounding box for both. Another addition is the adjustment of row separation, which I have done on row basis.

\documentclass{article}
\usepackage{tikz}
\usepackage{soul}
\usepackage{enumitem,array,showframe}   %% showframe just for demo
\begin{document}
\newenvironment{Myitemize}{%
\renewcommand{\labelitemi}{{}}%
\begin{itemize}[nosep]}{\end{itemize}}

\noindent
\begin{tabular}[t]{>{\raggedright\arraybackslash}p{\dimexpr0.5\textwidth-2\tabcolsep-2\arrayrulewidth\relax}
                   >{\raggedright\arraybackslash}p{\dimexpr0.5\textwidth-2\tabcolsep-2\arrayrulewidth\relax}}
\multicolumn{1}{c}{\ul{Discrete}} & \multicolumn{1}{c}{\ul{Continuous}} \\
\begin{enumerate}[nosep,leftmargin=*,series=mylist]
  \item Probability mass function (p.m.f.)
\begin{tikzpicture}[x=0.93cm]   %% just to get rid of badbox
        \draw (0,0)--(5,0);
        \draw (1,2)--(1,0);
        \draw (3,1)--(3,0);
        \draw (4,0.8)--(4,0);
\end{tikzpicture}
 \end{enumerate} &
\begin{Myitemize}
  \item Probability density function (p.d.f.)
\begin{tikzpicture}[x=0.93cm]   %% just to get rid of badbox
    \draw (0,0)--(5,0);
    \path[use as bounding box] (0,0) rectangle (5,2);  %% to make picture align
    \draw (0,.7) ..controls (3,2.5) and (4,.8) ..(5,.7);
    \end{tikzpicture}
\end{Myitemize} \\[-3ex]
    \begin{enumerate}[nosep,resume*=mylist]
    \item $f(x)$ gives $Pr(X=x)$
    \end{enumerate} &
    \begin{Myitemize}
      \item Not so; $Pr(X=x)=0$ always
    \end{Myitemize}\\[-3ex]
    \begin{enumerate}[nosep,resume*=mylist]
      \item Zero probability $\Rightarrow$ Impossibility
    \end{enumerate} &
    \begin{Myitemize}
      \item Zero probability events do occur
    \end{Myitemize}\\[-3ex]
    \begin{enumerate}[nosep,resume*=mylist]
      \item 
    \end{enumerate}&
    \begin{Myitemize}
      \item Can get positive probability (area under continuous curve) for intervals no matter how small
    \end{Myitemize}\\[-3ex]
    \begin{enumerate}[nosep,resume*=mylist]
      \item
    \end{enumerate}&
 \end{tabular}

\end{document}

enter image description here

share|improve this answer
    
Dear sir, thanks very much for the solution and hope you had a happy independence day! I wish to understand in detail the new things I have encountered in your excellent answer---especially the path and the bounding box for the tikzpicture, width options in p{} and something I wanted to understand for much time [-3ex] etc. (is it related to some baseline, please? –  Abhimanyu Arora Aug 16 at 13:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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