Tikz 水平居中

Tikz 水平居中

我正在尝试将以下 tikz 图像居中,但它没有正确居中,就像有一个左边距一样......它向右偏移太多,请 ATM 帮忙,我已经尝试过\centering并且\begin{center}

\begin{center}
        \resizebox{15cm}{15cm}{
            \definecolor{dbdbvq}{rgb}{0.8588235294117647,0.8588235294117647,0.3137254901960784}
            \definecolor{dbzsqq}{rgb}{0.8588235294117647,0.5725490196078431,0.}
            \definecolor{qqsczs}{rgb}{0.,0.17254901960784313,0.5725490196078431}
            \definecolor{qqafqq}{rgb}{0.,0.6862745098039216,0.}
            \definecolor{veqqzs}{rgb}{0.3686274509803922,0.,0.5725490196078431}
            \definecolor{cqcqcq}{rgb}{0.7529411764705882,0.7529411764705882,0.7529411764705882}

            \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=0.35714285714285715cm,y=0.35714285714285715cm]
                \draw [color=cqcqcq,, xstep=1.7857142857142858cm,ystep=1.7857142857142858cm] (-14.,-14.) grid (14.,14.);
                \draw[->,color=black] (-14.,0.) -- (14.,0.);

                \foreach \x in {-10.,-5.,5.,10.}
                    \draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt) node[below] {\footnotesize $\x$};
                    \draw[->,color=black] (0.,-14.) -- (0.,14.);

                \foreach \y in {-10.,-5.,5.,10.}
                    \draw[shift={(0,\y)},color=black] (2pt,0pt) -- (-2pt,0pt) node[left] {\footnotesize $\y$};
                    \draw[color=black] (0pt,-10pt) node[right] {\footnotesize $0$};

                \clip(-14.,-14.) rectangle (14.,14.);
                    \node[inner sep=0pt, opacity=0.5] (whitehead) at (0,0)
                        {\includegraphics[width=.25\textwidth,angle=-19.962]{Bil.png}};
                    \draw [->,line width=1.pt,color=veqqzs] (0.,0.) -- (0.,-12.);
                    \draw [->,line width=1.pt,color=qqafqq] (0.,0.) -- (4.01,11.04);
                    \draw [->,line width=1.pt,color=qqsczs] (0.,0.) -- (1.104,-0.401);
                    \draw[line width=2.pt] (-28.415610102473128,19.087651578067057) -- (-16.884268018623146,19.087651578067057);
                    \draw [->,line width=1.pt,color=dbzsqq] (0.,0.) -- (-9.42,3.42);
                    \draw [->,line width=1.pt,color=dbdbvq] (0.,0.) -- (-4.306,2.059);
                    \draw [line width=1.pt,domain=-14.:14.] plot(\x,{(--18.477050744352262--3.1540440892439214*\x)/-8.683453053679028});

                \begin{scriptsize}
                    \draw[color=veqqzs] (1.5082226051175684,-6.36778607203197) node {$\vec{FT}$};
                    \draw[color=qqafqq] (1.5082226051175684,7.988734822361365) node {$\vec{FN}$};
                    \draw[color=qqsczs] (0.8739987905058194,-1.2939955551379403) node {$\vec{FG}$};
                    \draw [fill=black] (-20.343670643778143,19.087651578067057) circle (2.5pt);
                    \draw[color=black] (-20.113043802101142,20.44258427291944) node {$a = 2$};
                    \draw[color=dbzsqq] (-5.583552776450169,3.2032278575635864) node {$\vec{FM}$};
                    \draw[color=dbdbvq] (-2.5277471242299248,1.9924369387593293) node {$\vec{FR}$};
                    \draw[color=black] (-29.684057731696626,8.219361664038365) node {$l$};
                \end{scriptsize}
            \end{tikzpicture}}
    \end{center}

我想要居中的图片来自以下文件

\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[danish]{babel}
\usepackage{pgf,tikz}
\usepackage{mathrsfs}
\usepackage{amsmath}
\usepackage{pgfplots}
\usepackage{hyperref}
\usetikzlibrary{arrows}
\pgfplotsset{compat=1.15}

\title{Vektor i planet}
\author{Anwdoandwonad}
\date{Januar 2018}

\setlength{\parindent}{0em}
\setlength{\parskip}{1em}
\bibliographystyle{alpha}

\begin{document}
    \begin{titlepage}
        \maketitle
        \begin{center}
            \resizebox{10cm}{10cm}{
            \begin{tikzpicture}
                \draw[thin,gray!40] (-2,-2) grid (2,2);
                \draw[<->] (-2,0)--(2,0) node[right]{$x$};
                \draw[<->] (0,-2)--(0,2) node[above]{$y$};
                \draw[line width=2pt,blue,-stealth](0,0)--(2,2) node[anchor=south west]{$\boldsymbol{\vec{u}}$};
                \draw[line width=2pt,green,-stealth](0,0)--(-2,-2) node[anchor=north east]{$\boldsymbol{\vec{-u}}$};
            \end{tikzpicture}}
        \end{center}

        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    \end{titlepage}

    \tableofcontents

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est \href{https://www.geogebra.org/m/nxqPCdU8}{laborum}. \cite{MatBog}

    \begin{center}
        \resizebox{15cm}{15cm}{
            \definecolor{dbdbvq}{rgb}{0.8588235294117647,0.8588235294117647,0.3137254901960784}
            \definecolor{dbzsqq}{rgb}{0.8588235294117647,0.5725490196078431,0.}
            \definecolor{qqsczs}{rgb}{0.,0.17254901960784313,0.5725490196078431}
            \definecolor{qqafqq}{rgb}{0.,0.6862745098039216,0.}
            \definecolor{veqqzs}{rgb}{0.3686274509803922,0.,0.5725490196078431}
            \definecolor{cqcqcq}{rgb}{0.7529411764705882,0.7529411764705882,0.7529411764705882}

            \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=0.35714285714285715cm,y=0.35714285714285715cm]
                \draw [color=cqcqcq,, xstep=1.7857142857142858cm,ystep=1.7857142857142858cm] (-14.,-14.) grid (14.,14.);
                \draw[->,color=black] (-14.,0.) -- (14.,0.);

                \foreach \x in {-10.,-5.,5.,10.}
                    \draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt) node[below] {\footnotesize $\x$};
                    \draw[->,color=black] (0.,-14.) -- (0.,14.);

                \foreach \y in {-10.,-5.,5.,10.}
                    \draw[shift={(0,\y)},color=black] (2pt,0pt) -- (-2pt,0pt) node[left] {\footnotesize $\y$};
                    \draw[color=black] (0pt,-10pt) node[right] {\footnotesize $0$};

                \clip(-14.,-14.) rectangle (14.,14.);
                    \node[inner sep=0pt, opacity=0.5] (whitehead) at (0,0)
                        {\includegraphics[width=.25\textwidth,angle=-19.962]{Bil.png}};
                    \draw [->,line width=1.pt,color=veqqzs] (0.,0.) -- (0.,-12.);
                    \draw [->,line width=1.pt,color=qqafqq] (0.,0.) -- (4.01,11.04);
                    \draw [->,line width=1.pt,color=qqsczs] (0.,0.) -- (1.104,-0.401);
                    \draw[line width=2.pt] (-28.415610102473128,19.087651578067057) -- (-16.884268018623146,19.087651578067057);
                    \draw [->,line width=1.pt,color=dbzsqq] (0.,0.) -- (-9.42,3.42);
                    \draw [->,line width=1.pt,color=dbdbvq] (0.,0.) -- (-4.306,2.059);
                    \draw [line width=1.pt,domain=-14.:14.] plot(\x,{(--18.477050744352262--3.1540440892439214*\x)/-8.683453053679028});

                \begin{scriptsize}
                    \draw[color=veqqzs] (1.5082226051175684,-6.36778607203197) node {$\vec{FT}$};
                    \draw[color=qqafqq] (1.5082226051175684,7.988734822361365) node {$\vec{FN}$};
                    \draw[color=qqsczs] (0.8739987905058194,-1.2939955551379403) node {$\vec{FG}$};
                    \draw [fill=black] (-20.343670643778143,19.087651578067057) circle (2.5pt);
                    \draw[color=black] (-20.113043802101142,20.44258427291944) node {$a = 2$};
                    \draw[color=dbzsqq] (-5.583552776450169,3.2032278575635864) node {$\vec{FM}$};
                    \draw[color=dbdbvq] (-2.5277471242299248,1.9924369387593293) node {$\vec{FR}$};
                    \draw[color=black] (-29.684057731696626,8.219361664038365) node {$l$};
                \end{scriptsize}
            \end{tikzpicture}}
    \end{center}

    \begin{center}
        \resizebox{10cm}{10cm}{
            $\hat{\hat{\hat{a}}}$
        }
    \end{center}

    \bibliography{Main}
\end{document}

答案1

欢迎!我稍微修改了您的文件。而不是,使用Ti 中的\resizebox选项scaleZ 图片。以后请去掉与问题无关的样式,也不要包含别人没有的图形文件。

\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[danish]{babel}
\usepackage{pgf,tikz}
\usepackage{mathrsfs}
\usepackage{amsmath}
\usepackage{pgfplots}
\usepackage{hyperref}
\usetikzlibrary{arrows}
\pgfplotsset{compat=1.15}

\title{Vektor i planet}
\author{Anwdoandwonad}
\date{Januar 2018}

\setlength{\parindent}{0em}
\setlength{\parskip}{1em}
\bibliographystyle{alpha}

\begin{document}
    \begin{titlepage}
        \maketitle
        \begin{center}
            \resizebox{10cm}{10cm}{
            \begin{tikzpicture}
                \draw[thin,gray!40] (-2,-2) grid (2,2);
                \draw[<->] (-2,0)--(2,0) node[right]{$x$};
                \draw[<->] (0,-2)--(0,2) node[above]{$y$};
                \draw[line width=2pt,blue,-stealth](0,0)--(2,2) node[anchor=south west]{$\boldsymbol{\vec{u}}$};
                \draw[line width=2pt,green,-stealth](0,0)--(-2,-2) node[anchor=north east]{$\boldsymbol{\vec{-u}}$};
            \end{tikzpicture}}
        \end{center}

        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    \end{titlepage}

    \tableofcontents

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est \href{https://www.geogebra.org/m/nxqPCdU8}{laborum}. \cite{MatBog}

    \begin{center}
%        \resizebox{15cm}{15cm}{ %<- removed in favor of scale
            \definecolor{dbdbvq}{rgb}{0.8588235294117647,0.8588235294117647,0.3137254901960784}
            \definecolor{dbzsqq}{rgb}{0.8588235294117647,0.5725490196078431,0.}
            \definecolor{qqsczs}{rgb}{0.,0.17254901960784313,0.5725490196078431}
            \definecolor{qqafqq}{rgb}{0.,0.6862745098039216,0.}
            \definecolor{veqqzs}{rgb}{0.3686274509803922,0.,0.5725490196078431}
            \definecolor{cqcqcq}{rgb}{0.7529411764705882,0.7529411764705882,0.7529411764705882}

            \begin{tikzpicture}[line cap=round,line join=round,>=triangle
            45,x=0.35714285714285715cm,y=0.35714285714285715cm,scale=1.3] %<- 
                \draw [color=cqcqcq,, xstep=1.7857142857142858cm,ystep=1.7857142857142858cm] (-14.,-14.) grid (14.,14.);
                \draw[->,color=black] (-14.,0.) -- (14.,0.);

                \foreach \x in {-10.,-5.,5.,10.}
                    \draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt) node[below] {\footnotesize $\x$};
                    \draw[->,color=black] (0.,-14.) -- (0.,14.);

                \foreach \y in {-10.,-5.,5.,10.}
                    \draw[shift={(0,\y)},color=black] (2pt,0pt) -- (-2pt,0pt) node[left] {\footnotesize $\y$};
                    \draw[color=black] (0pt,-10pt) node[right] {\footnotesize $0$};

                \clip(-14.,-14.) rectangle (14.,14.);
% Removed because I don't have the file "Bil.png"
%                     \node[inner sep=0pt, opacity=0.5] (whitehead) at (0,0)
%                         {\includegraphics[width=.25\textwidth,angle=-19.962]{Bil.png}};
                    \draw [->,line width=1.pt,color=veqqzs] (0.,0.) -- (0.,-12.);
                    \draw [->,line width=1.pt,color=qqafqq] (0.,0.) -- (4.01,11.04);
                    \draw [->,line width=1.pt,color=qqsczs] (0.,0.) -- (1.104,-0.401);
                    \draw[line width=2.pt] (-28.415610102473128,19.087651578067057) -- (-16.884268018623146,19.087651578067057);
                    \draw [->,line width=1.pt,color=dbzsqq] (0.,0.) -- (-9.42,3.42);
                    \draw [->,line width=1.pt,color=dbdbvq] (0.,0.) -- (-4.306,2.059);
                    \draw [line width=1.pt,domain=-14.:14.] plot(\x,{(--18.477050744352262--3.1540440892439214*\x)/-8.683453053679028});

%                \begin{scriptsize} %<- removed
                    \draw[color=veqqzs] (1.5082226051175684,-6.36778607203197) node {$\vec{FT}$};
                    \draw[color=qqafqq] (1.5082226051175684,7.988734822361365) node {$\vec{FN}$};
                    \draw[color=qqsczs] (0.8739987905058194,-1.2939955551379403) node {$\vec{FG}$};
                    \draw [fill=black] (-20.343670643778143,19.087651578067057) circle (2.5pt);
                    \draw[color=black] (-20.113043802101142,20.44258427291944) node {$a = 2$};
                    \draw[color=dbzsqq] (-5.583552776450169,3.2032278575635864) node {$\vec{FM}$};
                    \draw[color=dbdbvq] (-2.5277471242299248,1.9924369387593293) node {$\vec{FR}$};
                    \draw[color=black] (-29.684057731696626,8.219361664038365) node {$l$};
%                \end{scriptsize}
            \end{tikzpicture}%}
    \end{center}

    \begin{center}
        \resizebox{10cm}{10cm}{
            $\hat{\hat{\hat{a}}}$
        }
    \end{center}

    \bibliography{Main}
\end{document}

相关内容