I'm fairly new to LaTeX and I'm trying to make a homework template that uses figures generated in LaTeX but when I use TikZ I get a bounding box that is way too large. What is the easiest way to automatically get TikZ to make a tight bounding box?
Here is my code:
\documentclass{article}[12 pt]
\usepackage{amsmath,amssymb, amsthm, pgfplots} % Math packages
\pgfplotsset{compat=1.6}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage[margin=1in]{geometry} % Page settings
\usepackage{fancyhdr} %Used for headers
\usepackage{graphicx}
\pagestyle{fancy} % Sets page style to fancy
\fancyhf{} % Clears standard header
\lhead{\textbf{Algebra II}} %Subject Name
\chead{\textbf{Name:}\hspace{3 in}}
\rhead{\textbf{Mr. A}} %Teacher name
\rfoot{Page \thepage}
\begin{document}
\begin{flushright}
\textbf{Period:} \makebox[0.5 in]{\hrulefill} %Transfer this to header
\textbf{Date:} \makebox[0.75 in]{\hrulefill} \\[20 pt]
\end{flushright}
\center{\LARGE{\textbf{Intervals, Parent Functions and Domain \& Range}}}
%Create Question command
\center{Directions: Given a representation of an interval, give the other two representations. Below are examples of the three representations} \\
\begin{tikzpicture}
\begin{axis}[
axis y line=none,
axis lines=left,
axis line style={<->},
xmin=-5,
xmax=5,
ymin=0,
ymax=1,
%xlabel=$\mathbb R$,
scatter/classes={
o={mark=*,draw=black,fill=white},
c={mark=*,black}
},
restrict y to domain=0:1,
xtick={-5,-4,...,5},
point meta=explicit symbolic,
]
\addplot[scatter,black,ultra thick] table [y expr=0,meta index=1, header=false] {
-2 c
3 c
};
\end{axis}
\end{tikzpicture}
\end{document}
Best Answer
You could clip the plot although specifying the bounding box for the picture as Symbol1 suggests is probably better.
Clipping
Setting bounding box
Or you can set the bounding box explicitly:
Note that
center
is an environment and not a command.