如何修复 tikzpicture 代码中的问题?

如何修复 tikzpicture 代码中的问题?

我已经使用 geogebra 创建了 tikzpicture 代码,但尺寸太大,超出了页面大小。我尝试进行一些更改,但图形被打乱了。如何解决这个问题。我需要有关更改代码的建议。

    \documentclass[10pt]{book}
    \usepackage[paperheight=10in,paperwidth=9in, top=1in, bottom=0.8in, twocolumn, twoside]{geometry}
    \setlength{\columnseprule}{0.4pt}
    \usepackage{amssymb,amsfonts}
    \usepackage{mathrsfs}
    \usepackage[centertags]{amsmath}
    \usepackage{amsthm}
    \newtheorem{theorem}{Theorem}
    \usepackage{epsfig}
    \usepackage{graphicx}\graphicspath{{Graphics/}}
    \usepackage{amsthm}
    \usepackage{mathptmx}
    \usepackage[square,sort&compress]{natbib}
    \usepackage{pgf,tikz,pgfplots}
    \pgfplotsset{compat=1.15}
    \usetikzlibrary{arrows}
    \usepackage[T1]{fontenc}
    \usepackage{fancyhdr}\pagestyle{fancy}
    \usepackage{xcolor}
    \usepackage{setspace}
    \usepackage{booktabs}
    %\usepackage{hyperref}
    \usetikzlibrary{arrows.meta}
    \renewcommand{\baselinestretch}{1.5}
    \newcommand\aug{\fboxsep=-\fboxrule\!\!\!\fbox{\strut}\!\!\!}
    \theoremstyle{definition}
    \newtheorem{Thm}{Theorem}[section]
    \newtheorem{lem}[Thm]{Lemma}
    \newtheorem{pro}[Thm]{Proposition}
    \newtheorem{de}[Thm]{Definition}
    \newtheorem{re}[Thm]{Remark}
    \newtheorem{ex}[Thm]{Example}
    \newtheorem{cor}[Thm]{Corollary}
    \numberwithin{equation}{section}
    \definecolor{uuuuuu}{rgb}{0.26666666666666666,0.26666666666666666,0.26666666666666666}
    \begin{document}
    \begin{tikzpicture}
          \begin{axis}[
          x=1.0cm,y=1.0cm,
          axis lines=middle,
          xmin=-6.8,
          xmax=9.9,
          ymin=-2.8,
          ymax=9.5,
          xtick={-6.0,-5.0,...,9.0},
          ytick={-2.0,-1.0,...,9.0},]
          \draw [line width=1.pt] (2.,3.) circle (5.cm);
          \draw [->,line width=1.pt] (7.,0.) -- (7.,6.708133947655416);
          \draw [->,line width=1.pt] (8.242200921483082,8.) -- (-6.226420391391763,8.);
          \draw (7.212598648390091,6.8707027264517615) node[anchor=north west] {$x=7$};
          \draw (7.375167426553626,4.107033486913864) node[anchor=north west] {$(7,3)$};
          \draw (0.8182267072910508,9.959509523582353) node[anchor=north west] {$(2,8)$};
          \draw (-4.871680528432671,9.688561558921775) node[anchor=north west] {$y=8$};
          \draw [line width=1.pt,dotted] (0.,2.91486244240732)-- (7.,2.91486244240732);
          \draw [line width=1.pt,dotted] (1.9562081413576815,0.)-- (2.010397734289791,8.);
          \begin{scriptsize}
          \draw [fill=uuuuuu] (7.,0.) circle (2.0pt);
          \draw [fill=black] (2.010397734289797,2.8606728494752045) circle (2.0pt);
          \draw [fill=black] (7.,2.91486244240732) circle (2.0pt);
          \draw [fill=black] (2.010397734289791,8.) circle (2.0pt);
          \draw [fill=black] (0.,2.91486244240732) circle (2.0pt);
          \draw [fill=black] (1.9562081413576815,0.) circle (2.0pt);
          \end{scriptsize}
          \end{axis}
          \end{tikzpicture}
\end{document}

答案1

您可以尝试x post scale=0.5缩小y post scale=0.5轴。

注意:我在下面的代码中将\draw [fill=uuuuuu] (7.,0.) circle (2.0pt);其改为,因为它会产生错误。可能是由于您没有提供前言,所以出现了一些软件包错误。\draw [fill=black] (7.,0.) circle (2.0pt);

编辑:要缩小整个图片,您可以使用包\adjustbox{max width=\textwidth}{content}中的图片adjustbox。见下文。

\documentclass{article}

\usepackage{pgfplots}

\begin{document}
    \begin{tikzpicture}
        \begin{axis}[
            x=1.0cm,y=1.0cm,
            axis lines=middle,
            xmin=-6.8,
            xmax=9.9,
            ymin=-2.8,
            ymax=9.5,
            xtick={-6.0,-5.0,...,9.0},
            ytick={-2.0,-1.0,...,9.0},
            y post scale=1,
            x post scale=1,]
            \draw [line width=1.pt] (2.,3.) circle (5.cm);
            \draw [->,line width=1.pt] (7.,0.) -- (7.,6.708133947655416);
            \draw [->,line width=1.pt] (8.242200921483082,8.) -- (-6.226420391391763,8.);
            \draw (7.212598648390091,6.8707027264517615) node[anchor=north west] {$x=7$};
            \draw (7.375167426553626,4.107033486913864) node[anchor=north west] {$(7,3)$};
            \draw (0.8182267072910508,9.959509523582353) node[anchor=north west] {$(2,8)$};
            \draw (-4.871680528432671,9.688561558921775) node[anchor=north west] {$y=8$};
            \draw [line width=1.pt,dotted] (0.,2.91486244240732)-- (7.,2.91486244240732);
            \draw [line width=1.pt,dotted] (1.9562081413576815,0.)-- (2.010397734289791,8.);
            \begin{scriptsize}
                \draw [fill=black] (7.,0.) circle (2.0pt);
                \draw [fill=black] (2.010397734289797,2.8606728494752045) circle (2.0pt);
                \draw [fill=black] (7.,2.91486244240732) circle (2.0pt);
                \draw [fill=black] (2.010397734289791,8.) circle (2.0pt);
                \draw [fill=black] (0.,2.91486244240732) circle (2.0pt);
                \draw [fill=black] (1.9562081413576815,0.) circle (2.0pt);
            \end{scriptsize}
        \end{axis}
    \end{tikzpicture}
\end{document}

在此处输入图片描述

编辑:Adjustbox:将图片尺寸缩小至文本宽度。

  \documentclass[10pt]{book}
    \usepackage[paperheight=10in,paperwidth=9in, top=1in, bottom=0.8in, twocolumn, twoside]{geometry}
    \setlength{\columnseprule}{0.4pt}
    \usepackage{amssymb,amsfonts}
    \usepackage{mathrsfs}
    \usepackage[centertags]{amsmath}
    \usepackage{amsthm}
    \newtheorem{theorem}{Theorem}
    \usepackage{epsfig}
    \usepackage{graphicx}\graphicspath{{Graphics/}}
    \usepackage{amsthm}
    \usepackage{mathptmx}
    \usepackage[square,sort&compress]{natbib}
    \usepackage{pgf,tikz,pgfplots}
    \pgfplotsset{compat=1.15}
    \usetikzlibrary{arrows}
    \usepackage[T1]{fontenc}
    \usepackage{fancyhdr}\pagestyle{fancy}
    \usepackage{xcolor}
    \usepackage{setspace}
    \usepackage{booktabs}
    \usepackage{adjustbox}
    %\usepackage{hyperref}
    \usetikzlibrary{arrows.meta}
    \renewcommand{\baselinestretch}{1.5}
    \newcommand\aug{\fboxsep=-\fboxrule\!\!\!\fbox{\strut}\!\!\!}
    \theoremstyle{definition}
    \newtheorem{Thm}{Theorem}[section]
    \newtheorem{lem}[Thm]{Lemma}
    \newtheorem{pro}[Thm]{Proposition}
    \newtheorem{de}[Thm]{Definition}
    \newtheorem{re}[Thm]{Remark}
    \newtheorem{ex}[Thm]{Example}
    \newtheorem{cor}[Thm]{Corollary}
    \numberwithin{equation}{section}
    \definecolor{uuuuuu}{rgb}{0.26666666666666666,0.26666666666666666,0.26666666666666666}
    \begin{document}
    \adjustbox{max width=\textwidth}{
    \begin{tikzpicture}
          \begin{axis}[
          x=1.0cm,y=1.0cm,
          axis lines=middle,
          xmin=-6.8,
          xmax=9.9,
          ymin=-2.8,
          ymax=9.5,
          xtick={-6.0,-5.0,...,9.0},
          ytick={-2.0,-1.0,...,9.0},]
          \draw [line width=1.pt] (2.,3.) circle (5.cm);
          \draw [->,line width=1.pt] (7.,0.) -- (7.,6.708133947655416);
          \draw [->,line width=1.pt] (8.242200921483082,8.) -- (-6.226420391391763,8.);
          \draw (7.212598648390091,6.8707027264517615) node[anchor=north west] {$x=7$};
          \draw (7.375167426553626,4.107033486913864) node[anchor=north west] {$(7,3)$};
          \draw (0.8182267072910508,9.959509523582353) node[anchor=north west] {$(2,8)$};
          \draw (-4.871680528432671,9.688561558921775) node[anchor=north west] {$y=8$};
          \draw [line width=1.pt,dotted] (0.,2.91486244240732)-- (7.,2.91486244240732);
          \draw [line width=1.pt,dotted] (1.9562081413576815,0.)-- (2.010397734289791,8.);
          \begin{scriptsize}
          \draw [fill=uuuuuu] (7.,0.) circle (2.0pt);
          \draw [fill=black] (2.010397734289797,2.8606728494752045) circle (2.0pt);
          \draw [fill=black] (7.,2.91486244240732) circle (2.0pt);
          \draw [fill=black] (2.010397734289791,8.) circle (2.0pt);
          \draw [fill=black] (0.,2.91486244240732) circle (2.0pt);
          \draw [fill=black] (1.9562081413576815,0.) circle (2.0pt);
          \end{scriptsize}
          \end{axis}
          \end{tikzpicture}}
\end{document}

在此处输入图片描述

相关内容