[Tex/LaTex] Can the LaTeX (maths) code be improved

best practicesformattingmath-modenotestypography

I feel that my code isn't written very efficiently.

\documentclass[a4paper,11pt]{article}
\usepackage[english]{babel}
\usepackage[pdftex]{graphicx}
\usepackage{tikz}
\usepackage{wasysym}
\usepackage[all]{xy}
\usepackage{amsfonts}

\title{Discrete Mathematics -- Lecture 15}
\author{Alec Taylor}
\date{August 25, 2011}

\begin{document}

\maketitle

\section{Disjoint definition}
Sets A and B are \underline{disjoint} if A $\cap$ B = \{ c,d,e \}
\\[2mm]
But if C=\{ x,y,z \} then A and C are disjoint, B and C are disjoint.
\begin{center}
\line(1,0){250}
\end{center}

Note: A $\subseteq$ A so A $\in$  $\mathcal{P}$(A)
\\[2mm]
$\mathcal{P}$ $\subseteq$ A so $\emptyset$ $\in$ $\mathcal{P}$(A)
\\[2mm]
x $\in$ A, \{x\} A, \{x\} $\in$ $\mathcal{P}$(A)

\section{Cartesian definition}
The \underline{cartesian product} of the set $A_1$, $A_2$, ..., $A_n$ is $A_1$ $\times$ $A_2$ $\times$ ... $\times$ $A_n$ 
\newline
=\{($a_1$, $a_2$, ..., $a_n$)(a, $\in$$A_1$)$\land$($a_2$$\in$$A_2$)$\land$...$\land$($a_n$$\in$$A_n$)\}
\\[2mm]
The element ($a_1$, $a_2$, ..., $a_n$) is an \underline{ordered n-tuple}.
\\[2mm]
E.g.: (x,y) in cartesian plan (i.e.: the coordiantes of a point in the plane) is an ordered pair, the Cartesian plane is the product $\mathbb{R}$x$\mathbb{R}$ or $\mathbb{R}^2$.

\section{Cardinality definition}
In general if $\|$A$\|$=n, $\|$B$\|$=m then $\|$A $\times$ B$\|$ = $\|$A$\|$ $\|$B$\|$
\\[2mm]
$\|$$A^n$$\|$=$\|$A$\|$ $\|$A$\|$ (<n times>) $\|$A$\|$ = $\|$$A^n$$\|$
\end{document}
\documentclass[a4paper,11pt]{article}
\usepackage[english]{babel}
\usepackage[pdftex]{graphicx}
\usepackage{tikz}
\usepackage{wasysym}
\usepackage[all]{xy}
\usepackage{amsfonts}

\title{Discrete Mathematics -- Lecture 16}
\author{Alec Taylor}
\date{August 25, 2011}

\begin{document}

\maketitle

\section{Laws}
Let A = \{ x $\in$ $\mathbb{Z}$ $\|$  x $\le$ 5 \}
\newline
Let B = \{ x $\in$ $\mathbb{Z}$ $\|$ x $>$ 0 \}
\\[2mm]
A $\cap$ B = \{ x $\in$ $\mathbb{Z}$ $\|$ (x $\le$ 5) $\land$ (x $>$0) \}
\newline
= \{ 1,2,3,4,5 \}
\\[2mm]
A $\cup$ B = \{ x $\in$ $\mathbb{Z}$ $\|$ (x $\le$ 5) $\lor$ (x $>$ 0) \} = $\mathbb{Z}$
\\[2mm]
$\bar{A}$ = \{ x $\in$ $\mathbb{Z}$  $\|$ x $>$ 5 \}
\newline
= \{x $\in$ $\mathbb{Z}$ $\|$-(x$\le$5) \}
\\[2mm]
A $\cap$ $\mathbb{P}$ = A
\\[2mm]
A $\cap$ $\bar{A}$ = $\diameter$
\\[2mm]
A $\cap$ $\diameter$ = $\diameter$
\\[2mm]
A $\cup$ (A $\cap$ B) $\equiv$ A
\\[2mm]
A $\cap$ B
\begin{tikzpicture}
\filldraw[fill=gray] (-2,-2) rectangle (3,2);
\scope % A \cap B
\clip (0,0) circle (1);
\fill[white] (1,0) circle (1);
\endscope
% outline
\draw (0,0) circle (1)
      (1,0) circle (1);
\end{tikzpicture}
\\[2mm]
$\overline{A \cap B}$ \tikz \fill[even odd rule] (0,0) circle (1) (1,0) circle (1);

\section{Equivalency}
Two expressions involving sets are equivalent if ew can represent them with the same venn diagram. This corresponds to using truthg tables to establish equivalence of logical expressions.

\subsection{Examples}
\subsubsection{Example 1}
Let $\mathbb{P}$ = \{ 1,2, ..., 10 \}
\newline
A = \{ 2,4,7,9 \}
\newline
B = \{ 1,4,6,7,10 \}
\newline
C = \{ 3,5,7,9 \}

\subsubsection{Example 2}
Find B $\cap$ $\bar{C}$
\newline
$\bar{C}$=\{1,2,4,6,8,10\}
\newline
So B $\cap$ $\bar{C}$ = \{1,4,6,10\}

\subsubsection{Example 3}
Find (A $\cap$ $\bar{B}$) $\cup$ C = (A $\cap$ \{ 2,3,5,9,9 \}) $\cup$ C = \{ 2,9 \} $\cup$ C = \{ 2,3,5,7,9 \}
\subsubsection{Example 4}
Find $\overline{B \cup C}$ $\cap$ C = \{ $\overline{1,3,4,5,6,7,8,10}$\} $\cap$ C = \{ 2,8 \} $\cap$ C = $\diameter$

\subsubsection{Example 5}
Show that  (A $\cup$ $\bar{B}$) $\cap$ (A $\cup$ B) = A
\newline
(A $\cup$ $\bar{B}$) $\cap$ (A $\cup$B) = ((A $\cup$ $\bar{B}$) $\cap$ A) $\cup$ ((A $\cup$ $\bar{B}$) $\cap$ B) \underline{\bf distr}
\newline
=((A $\cup$ $\bar{B}$) $\cap$ A) $\cup$ ((A $\cap$ B) $\cup$ ($\bar{B}$ $\cap$ B)) \underline{\bf distr}
\newline
= A $\cup$ ((A$\cap$B)$\cup$($\bar{B}$ $\cap$ B)) \underline{\bf absorption}
\newline
= A $\cup$ (A $\cap$ B) \underline{\bf identity}
\newline
= {\bf A}
\end{document}

Is there a better way of writing it?

FYI: I type up these notes during the lectures.

Best Answer

Here's my nomination for how to rewrite Lecture 16. The new version makes use of constructs of the amsmath, amssymb, and ntheorem packages. I've also simplified most of the math expressions, at least relative to the initial forms. Some \mathstruts were inserted to raise the overline parts a bit. The command \varnothing now denotes the empty set. Finally, I've put the two diagrams into center environments so that they're each centered on the page (along with their respective captions).

enter image description here

enter image description here

\documentclass[a4paper,11pt]{article}
\usepackage{graphicx,tikz}
\usepackage[all]{xy}
\usepackage{amsmath,amssymb,ntheorem}

\usepackage{ntheorem}
\theoremstyle{break}
\theorembodyfont{\upshape}
\newtheorem{example}{Example}

\title{Discrete Mathematics --- Lecture 16}
\author{Alec Taylor}
\date{August 25, 2011}

\begin{document}
\maketitle

\section{Laws}

Let $\mathbb{P}=\mathbb{Z}$, $A = \{ x\in\mathbb{Z} \mid x \le 5 \}$, 
and $B = \{ x\in\mathbb{Z} \mid x > 0 \}$. Then:
\begin{align*}
     A \cap B &= \{ x\in\mathbb{Z} \mid (x \le 5) \land (x >0) \} \\
              &= \{ 1,2,3,4,5 \} \\    
     A \cup B &= \{ x\in\mathbb{Z} \mid (x \le 5) \lor (x > 0) \} =\mathbb{Z}\\    
     \bar{A}  &= \{ x\in\mathbb{Z} \mid x > 5 \}\\                  
              &= \{ x\in\mathbb{Z} \mid -(x\le5) \}\\    
 A\cap\mathbb{P} &= A\\
 A \cap \bar{A}  &= \varnothing\\    
 A \cap \varnothing  &= \varnothing\\    
 A \cup (A \cap B) &\equiv A 
\end{align*}

\begin{center}
$A \cap B$

\medskip
\begin{tikzpicture}
\filldraw[fill=gray] (-2,-2) rectangle (3,2);
\scope % A \cap B
\clip (0,0) circle (1);
\fill[white] (1,0) circle (1);
\endscope
% outline
\draw (0,0) circle (1)
      (1,0) circle (1);
\end{tikzpicture}
\end{center}

\medskip
\begin{center}
$\overline{\mathstrut A \cap B}$ 

\medskip
\tikz \fill[even odd rule] (0,0) circle (1) (1,0) circle (1);
\end{center}


\section{Equivalency}

Two expressions involving sets are equivalent if we 
can represent them with the same venn diagram. 
This corresponds to using truth tables to establish 
equivalence of logical expressions.

\subsection{Examples}
\raggedright
Let $\mathbb{P}= \{ 1,2, \dots, 10 \}$,     
$A = \{ 2,4,7,9 \}$,  
$B = \{ 1,4,6,7,10 \}$, and   
$C = \{ 3,5,7,9 \}$.

\begin{example}    
Find $B \cap \bar{C}$.
\[
\bar{C}=\{1,2,4,6,8,10\}.\quad
\text{So $B \cap \bar{C} = \{1,4,6,10\}$}\,.
\]
\end{example}

\begin{example}    
Find $(A \cap \bar{B}) \cup C$.
\[
A \cap \bar{B} = A \cap \{ 2,3,5,9 \} = \{ 2,9 \}. 
\quad\text{Hence $(A \cap \bar{B})\cup C = \{ 2,3,5,7,9 \}$}\,.
\]
\end{example}

\begin{example}    
Find $\overline{\mathstrut B \cup C} \cap C$.
\[
\overline{\mathstrut B \cup C} \cap C = \overline{\{ 1,3,4,5,6,7,8,10\} } \cap  C 
= \{ 2,8 \} \cap C = \varnothing\,.
\]
\end{example}

\begin{example}
Show that  $(A \cup \bar{B}) \cap (A \cup B) = A$.
\begin{align*}
(A \cup \bar{B}) \cap (A \cup B) 
&= \bigl((A \cup \bar{B}) \cap A\bigr) \cup 
   \bigl((A \cup \bar{B}) \cap B\bigr) 
   \quad\textbf{distr}\\    
&= \bigl((A \cup \bar{B}) \cap A\bigr) \cup 
   \bigl((A \cap B) \cup (\bar{B} \cap B) \bigr) 
   \quad\textbf{distr}\\    
&= A \cup \bigl((A\cap B)\cup(\bar{B} \cap B)\bigr) 
     \quad\textbf{absorption}\\    
&= A \cup (A \cap B) 
   \quad\textbf{identity}\\    
&= A
\end{align*}
\end{example}

\end{document}
Related Question