Page LayoutFirst page is blank, figure is shifted to right

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
skylla
Posts: 2
Joined: Mon Oct 26, 2009 4:52 pm

First page is blank, figure is shifted to right

Post by skylla »

Hi, I am somewhat new to LaTeX. I am using TeXworks with the pgf and tikz packages and the automata library to draw an FST. I use the document class of article and layout of landscape. Otherwise, all I am doing is drawing a Finite State Transducer. The first page is blank, and the FST starts almost horizontally center of the page and vertically below center of the page. My code is below. I would like the FST to be on the first page, and more centered, any help?

Code: Select all

\documentclass[landscape]{article}
\pagestyle{empty}
\usepackage[rgb]{xcolor}
\usepackage{pgf}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[->,shorten >=1pt,node distance=5cm,auto,thick,bend angle=45, minimum size=5mm, >=stealth]
\usetikzlibrary{automata}
\node[state,accepting] (q_0)[]{$q_0$};
\node[state] (q_1) [right of=q_0] {$q_1$};
\node[state] (q_2) [below right of=q_1] {$q_2$};
\node[state] (q_3) [above right of=q_2] {$q_3$};
\node[state] (q_4) [above of=q_3] {$q_4$};
\node[state] (q_5) [above of=q_2] {$q_5$};
\node[state] (q_8) [left of=q_2,fill=orange,text=blue] {$q_8$};
\node[state] (q_6) [below left of=q_2,fill=cyan,text=blue] {$q_6$};
\node[state] (q_7) [right of=q_6,fill=red,text=blue] {$q_7$};
\node[state] (q_9) [above right of=q_0,fill=magenta,text=blue] {$q_9$};
\path [every node/.style={font=}, line width=2pt]
	(q_0) 	edge	[loop left]				(q_0)
		edge	[bend right=10]			(q_9)
		edge	[bend left=10]				(q_1)
		edge	[bend right=30]			(q_6)
		edge	[bend right=25]			(q_8)
	(q_1) 	edge	[loop above]				(q_1)
		edge	[bend left=10]				(q_0)
		edge	[bend left=10]				(q_2)
		edge	[bend left=25, color=blue]		(q_6)
		edge	[bend right=10, color=blue]		(q_8)
	(q_2) 	edge	[bend right=0]				(q_0)
		edge	[bend left=10]				(q_1)
		edge	[bend left=10]				(q_5)
		edge	[bend right=10]			(q_3)
		edge	[bend right=10, color=green]		(q_6)
		edge	[bend left=10, color=green]		(q_8)
	(q_3) 	edge	[bend right=10]			(q_4)
	(q_4)	edge	[bend right=60]			(q_0)
	(q_5)	edge	[bend right=20]			(q_0)
		edge	[bend right=10]			(q_1)
		edge	[bend left=10]				(q_2)
	(q_6) 	edge	[loop below, color=gray]		(q_6)
		edge	[bend left=10, color=cyan]		(q_1)
		edge	[bend left=10, color=cyan]		(q_7)
		edge	[bend left=15, color=cyan]		(q_8)
		edge	[bend left=20, color=cyan]		(q_0)
	(q_7) 	edge	[bend left=90, color=red]		(q_0)
		edge	[bend right=45, color=red]		(q_1)
		edge	[bend right=10, color=red]		(q_2)
		edge	[bend left=10, color=red]		(q_6)
		edge	[bend right=10, color=red]		(q_8)
	(q_8) 	edge	[loop left, color=orange]		(q_8)	
		edge	[bend right=10, color=orange]	(q_0)
		edge	[bend left=7, color=orange]		(q_6)
		edge	[bend right=10, color=orange]	(q_7)
	(q_9) 	edge	[bend right=10, color=magenta]	(q_0)
		edge	[loop right, color=magenta]		(q_9);
\end{tikzpicture}
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Stefan Kottwitz
Site Admin
Posts: 10323
Joined: Mon Mar 10, 2008 9:44 pm

First page is blank, figure is shifted to right

Post by Stefan Kottwitz »

Hi skylla,

welcome to the board!
That's a good code example. Btw. the forum provides a code environment for better readability, I will insert the code tags into your post to show it.

Your TikZ picture is too big to fit to the page, you should get a warning "Overfull \vbox". You could make it smaller or change the margins, like

Code: Select all

\usepackage[top=7mm]{geometry}
Stefan
LaTeX.org admin
skylla
Posts: 2
Joined: Mon Oct 26, 2009 4:52 pm

Re: First page is blank, figure is shifted to right

Post by skylla »

Thanks, that worked, you're awesome! One question though, I was not getting a warning and the graphic did fit on a page, it was just displaying on the second page and shifted funny. Any particular reason my code did that? Changing the top margin as you suggested placed the picture nicely centered on the first page.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10323
Joined: Mon Mar 10, 2008 9:44 pm

Re: First page is blank, figure is shifted to right

Post by Stefan Kottwitz »

The standard margins were just so big that the figure didn't fit to the page, and what's not fitting will be moved to the next page. The margins are not visible, causing the impression the picture might fit.

Stefan
LaTeX.org admin
Post Reply