未知的 tikz 图片错误

未知的 tikz 图片错误

我真的不知道问题出在哪里,但不知为何,这段代码只能工作一次。我把它放在一个活动文档中,它工作正常,但现在当我尝试第二次复制和粘贴它时,它不起作用——它与另一个工作正常的代码完全相同。我甚至创建了一个具有相同前言的新文件,但它不再起作用——这真的没有意义。这似乎完全是标记为“%angle”的部分的问题。这很令人沮丧,因为我的作业今天就要交了,而我真的很没时间。以下是我所拥有的:

\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[fleqn]{amsmath}
\usepackage{esint}
\usepackage[none]{hyphenat}
\usepackage{fancyhdr}
\usepackage{multicol}
\usepackage[pdftex]{graphicx}
\usepackage{caption}
\usepackage{lastpage}
\usepackage{array} 
\usepackage{cellspace}
\usepackage{scrextend}
\usepackage{nicefrac}
\usepackage{tikz-cd}
\usepackage{mathtools}
\usepackage{enumitem}
\usepackage{tikz}
\usetikzlibrary{scopes}
\usepackage{verbatim}
\usepackage{textcomp}
\usepackage{gensymb}
\usepackage[autostyle]{csquotes}
\usepackage{relsize}
\usepackage{bigints}
\usepackage{tabularx}
\usepackage[margin=1.5cm]{caption}
\captionsetup[table]{labelfont={bf}}
\captionsetup[figure]{labelfont={bf}}


\setlength{\mathindent}{0.5in}
\pagestyle{fancy}
\lhead{}
\rhead{}
\chead{}
\cfoot{Page \thepage \hspace{1pt} of \pageref{LastPage}}

%\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

\newcommand\Mydiv[2]{%
\strut#1\kern.25em\smash{\raise.3ex\hbox{\big)}}\mkern-8mu
        \overline{\enspace\strut#2}}

\makeatletter
\renewcommand*\env@matrix[1][c]{\hskip -\arraycolsep
  \let\@ifnextchar\new@ifnextchar
  \array{*\c@MaxMatrixCols #1}}
\makeatother

\parindent 0ex

\begin{document}
\renewcommand{\baselinestretch}{1.5}


            \begin{tikzpicture}[
                            force/.style={>=latex,draw=black,fill=black},
                            axis/.style={densely dashed,gray,font=\small},
                            M/.style={rectangle,draw,fill=lightgray,minimum size=0.01cm,thin},
]
                            \matrix[column sep=2.5cm] {

                                &
                                % Free body diagram of M1
                                \begin{scope}[rotate=0]
                                    \node[M,transform shape] (M) {};
                                        % Draw axes and help lines
                                            {[axis, -]
                                            \draw (1.5,-1.5) -- (M)


                                                                                        {};
                                % angles
                                \draw[solid,shorten, >=0.5pt] (-45:\arcr)
                                        arc(-45:-90:0.5cm);
                                        \node at (0.28,-0.65) {$\alpha$};


                                 }

                                    % Forces
                                    {[force,->, very thick]
                                        \draw (M) -- ++ (-1.5, 1.5) node[above] {$\textbf{N}_1$};
                                        \draw (M) -- ++ (1.5,1.5) node[above] {$\textbf{T}_1$};
                                        \draw node[right] {$\hspace{0.05in}m_1$};
                                        \draw (M) -- ++ (0,-1.5) node[below] {$\textbf{W}_1$};}

                                \end{scope}

                                &
                                % Free body diagram of M2
                                \begin{scope}[rotate=0]
                                    \node[M,transform shape] (M) {};
                                        % Draw axes and help lines
                                            {[axis, -]
                                            \draw (1.5,-1.5) -- (M)


                                                                                        {};
                                % angles
                                \draw[solid,shorten >=0.5pt] (-45:\arcr)
                                        arc(-45:-90:0.5cm);
                                        \node at (0.28,-0.65) {$\alpha$};


                                 }

                                    % Forces
                                    {[force,->, very thick]
                                        \draw (M) -- ++ (-1.5, 1.5) node[above] {$\textbf{N}_2$};
                                        \draw (M) -- ++ (-1.5,-1.5) node[above left] {$\textbf{T}_2$};
                                        \draw (M) -- ++ (1.5,1.5) node[above left] {\textbf{F}};                                        

                                        \draw node[right] {$\hspace{0.05in}m_2$};
                                        \draw (M) -- ++ (0,-1.5) node[below] {$\textbf{W}_2$};}

                                \end{scope}

\\
};
                        \end{tikzpicture}


\end{document}

我得到的错误是“!包 pgf 错误:未知箭头类型‘0.5pt’。”等等。如果我删除绘制弧的部分,错误就会消失。我很感激任何帮助,但我真的不太了解 LaTeX。

编辑:通常情况下是这样的

图表

答案1

这里有一个建议,可以减少角度的缺陷。使用angles为此而制作的库。我也会先绘制矢量,然后您可以使用它们来定义角度。

\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{fancyhdr}
\usepackage[fleqn]{amsmath}
\usepackage{tikz}
\usetikzlibrary{angles,scopes,quotes}
\setlength{\mathindent}{0.5in}
\pagestyle{fancy}
\lhead{}
\rhead{}
\chead{}
\cfoot{Page \thepage \hspace{1pt} of \pageref{LastPage}}

%\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

\newcommand\Mydiv[2]{%
\strut#1\kern.25em\smash{\raise.3ex\hbox{\big)}}\mkern-8mu
        \overline{\enspace\strut#2}}

\makeatletter
\renewcommand*\env@matrix[1][c]{\hskip -\arraycolsep
  \let\@ifnextchar\new@ifnextchar
  \array{*\c@MaxMatrixCols #1}}
\makeatother

\parindent 0ex

\begin{document}
\renewcommand{\baselinestretch}{1.5}
\begin{figure}[htb]
\centering
\begin{tikzpicture}[
    force/.style={>=latex,draw=black,fill=black},
    axis/.style={densely dashed,gray,font=\small},
    M/.style={rectangle,draw,fill=lightgray,minimum size=0.01cm,thin},
]                           \def\arcr{0.5cm}
\matrix[column sep=2.5cm] {
        % Free body diagram of M1
  \begin{scope}[rotate=0]
      \node[M,transform shape] (M) {};
          % Draw axes and help lines
      % Forces
      {[force,->, very thick]
          \draw (M) -- ++ (-1.5, 1.5) node[above] {$\mathbf{N}_1$};
          \draw (M) -- ++ (1.5,1.5) node[above] {$\mathbf{T}_1$};
          \draw node[right] {$\hspace{0.05in}m_1$};
          \draw (M) -- ++ (0,-1.5) node[below] (W1) {$\mathbf{W}_1$};}
      {[axis, -]
              \draw (1.5,-1.5) coordinate (A) -- (M);
               % angles
              \pic [draw,solid,->,angle radius=0.5cm,"$\alpha$",
                angle eccentricity=1.5] {angle = W1--M--A}; 
            }

  \end{scope}
  &
  % Free body diagram of M2
  \begin{scope}[rotate=0]
      \node[M,transform shape] (M) {};
          % Forces
          {[force,->, very thick]
              \draw (M) -- ++ (-1.5, 1.5) node[above] {$\mathbf{N}_2$};
              \draw (M) -- ++ (-1.5,-1.5) node[above left] {$\mathbf{T}_2$};
              \draw (M) -- ++ (1.5,1.5) node[above left] {$\mathbf{F}$};                                        
              \draw node[right=0.05in] {$m_2$};
              \draw (M) -- ++ (0,-1.5) node[below] (W2) {$\mathbf{W}_2$};}
          % Draw axes and help lines
              {[axis, -]
              \draw (1.5,-1.5) coordinate (A') -- (M);
              \pic [draw,solid,->,angle radius=0.5cm,"$\alpha$",
                angle eccentricity=1.5] {angle = W2--M--A}; 
               }
  \end{scope}
\\
};
\end{tikzpicture}
\caption{Some forces.}
\end{figure}

\end{document}

在此处输入图片描述

我删除了与图片无关的样式。但是,如果您将此代码放入文档中,请确保使用以下方式加载此处使用的库:

\usetikzlibrary{angles,scopes,quotes}

还要注意,这\textbf不是为数学模式设计的,所以我将其更改为\mathbf(但我更喜欢\boldsymbol,但这是一个品味问题)。

相关内容