\documentclass[oneside]{book}
\usepackage{geometry}% For the margins.
\usepackage{lipsum}
\newgeometry{
top=1in,
bottom=1in,
outer=1in,
inner=1in,
}
\usepackage{setspace}%Spacing between entries in array.
\doublespacing% Self explanatory.
\usepackage[justification=centering]{caption}
%\setlength{\textfloatsep}{-10pt}
\usepackage[toc,page]{appendix}%for the appendix
\usepackage{amsmath,amsthm,amssymb,amsfonts}
\usepackage{pgf,tikz}%plots,pics, drawings, etc.
\usepackage{tikz-3dplot}%For 3-D plots
\usepackage{mathrsfs}% For fancy "F"
\usetikzlibrary{arrows}
\usepackage{float}
%\usepackage{tikzpicture}
\usepackage{mathtools}
\usepackage{gensymb}% for degree symbol.
%\usepackage{pgfplots}%For coordinate plane
%\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings,backgrounds,patterns}
\usepackage{cancel}
\usepackage{color}
\usepackage{polynom}
\usepackage{graphicx}
\usepackage{fouriernc}
\usepackage[T1]{fontenc}
\usepackage{fancyhdr}%Shorten Section/Chapter titles in the headers of pages.
\pagestyle{fancy}
\usepackage{listing}
\usepackage{qtree}% For drawing trees.
\usepackage{pstricks,pst-node,pst-tree,pstricks-add}%This might be better.df
\setlength{\parskip}{1em}%Space between paragraphs.
\usepackage{multicol}
\begin{document}
\begin{figure}[h]
\begin{center}%\centering
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm, scale=1]%line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm, scale=1
\clip(-4,-1.6) rectangle (5.5,1.6);
\draw [line width=0.35mm, loosely dotted] (0.,0.)-- (2.,0.);
\draw [line width=0.35mm] (0.,0.)-- (1.,1.);
\draw [line width=0.35mm] (0.,0.)-- (1.,-1.);
\draw [line width=0.35mm, loosely dotted] (1.,1.)-- (2.,0.);
\draw [line width=0.35mm] (1.,-1.)-- (2.,0.);
\draw [line width=0.35mm] (2.,0.)-- (3.,1.);
\draw [line width=0.35mm, loosely dotted] (2.,0.)-- (3.,-1.);
\draw [line width=0.35mm] (2.,0.)-- (4.,0.);
\draw [line width=0.35mm] (3.,1.)-- (4.,0.);
\draw [line width=0.35mm, loosely dotted] (3.,-1.)-- (4.,0.);
\begin{scriptsize}
\draw [fill=black] (0.,0.) circle (2pt) node[yshift=0.4cm] {\large A};
\draw[fill=black] (1,1) circle (2pt) node[yshift=0.4cm] {\large B};
\draw[fill=black] (1,-1) circle (2pt) node[yshift=-0.4cm] {\large C};
\draw [fill=black] (2.,0.) circle (2pt) node[yshift=0.4cm] {\large D};
\draw [fill=black] (4.,0.) circle (2pt) node[yshift=0.4cm] {\large E};
\draw[fill=black] (3,-1) circle (2pt) node[yshift=-0.4cm] {\large F};
\draw[fill=black] (3,1) circle (2pt) node[yshift=0.4cm] {\large G};
\end{scriptsize}
\end{tikzpicture}
\caption{Example of a graph with open and closed edges.} \label{1}
\end{center}
\end{figure}
\end{document}
我需要做什么才能使我从 GeoGebra 获得的图形位于论文的中心?
答案1
GeoGebra 提供的输出总是包含一个\clip
大多数时候都是错误的指令。
\clip
以下是注释掉该行后的输出:
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm, scale=1]%line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm, scale=1
%\clip(-4,-1.6) rectangle (5.5,1.6);
\draw [line width=0.35mm, loosely dotted] (0.,0.)-- (2.,0.);
\draw [line width=0.35mm] (0.,0.)-- (1.,1.);
\draw [line width=0.35mm] (0.,0.)-- (1.,-1.);
\draw [line width=0.35mm, loosely dotted] (1.,1.)-- (2.,0.);
\draw [line width=0.35mm] (1.,-1.)-- (2.,0.);
\draw [line width=0.35mm] (2.,0.)-- (3.,1.);
\draw [line width=0.35mm, loosely dotted] (2.,0.)-- (3.,-1.);
\draw [line width=0.35mm] (2.,0.)-- (4.,0.);
\draw [line width=0.35mm] (3.,1.)-- (4.,0.);
\draw [line width=0.35mm, loosely dotted] (3.,-1.)-- (4.,0.);
\begin{scriptsize}
\draw [fill=black] (0.,0.) circle (2pt) node[yshift=0.4cm] {\large A};
\draw[fill=black] (1,1) circle (2pt) node[yshift=0.4cm] {\large B};
\draw[fill=black] (1,-1) circle (2pt) node[yshift=-0.4cm] {\large C};
\draw [fill=black] (2.,0.) circle (2pt) node[yshift=0.4cm] {\large D};
\draw [fill=black] (4.,0.) circle (2pt) node[yshift=0.4cm] {\large E};
\draw[fill=black] (3,-1) circle (2pt) node[yshift=-0.4cm] {\large F};
\draw[fill=black] (3,1) circle (2pt) node[yshift=0.4cm] {\large G};
\end{scriptsize}
\end{tikzpicture}
以下是删除%
之前内容后得到的结果:\clip
无论如何,代码都应该完善。例如,scriptsize
环境很有趣。我还会删除\large
命令并简化一些构造。
\begin{tikzpicture}[
line cap=round,
line join=round,
>=triangle 45,
x=1.0cm,
y=1.0cm,
scale=1
]
\draw [line width=0.35mm, loosely dotted] (0,0)-- (2,0);
\draw [line width=0.35mm] (0,0)-- (1,1);
\draw [line width=0.35mm] (0,0)-- (1,-1);
\draw [line width=0.35mm, loosely dotted] (1,1)-- (2,0);
\draw [line width=0.35mm] (1,-1)-- (2,0);
\draw [line width=0.35mm] (2,0)-- (3,1);
\draw [line width=0.35mm, loosely dotted] (2,0)-- (3,-1);
\draw [line width=0.35mm] (2,0)-- (4,0);
\draw [line width=0.35mm] (3,1)-- (4,0);
\draw [line width=0.35mm, loosely dotted] (3,-1)-- (4,0);
\fill (0,0) circle (2pt) node[yshift=0.4cm] {A};
\fill (1,1) circle (2pt) node[yshift=0.4cm] {B};
\fill (1,-1) circle (2pt) node[yshift=-0.4cm] {C};
\fill (2,0) circle (2pt) node[yshift=0.4cm] {D};
\fill (4,0) circle (2pt) node[yshift=0.4cm] {E};
\fill (3,-1) circle (2pt) node[yshift=-0.4cm] {F};
\fill (3,1) circle (2pt) node[yshift=0.4cm] {G};
\end{tikzpicture}