我将其完美地移至tikzpicture
外部文件。但将其呈现为独立文档似乎忽略了包xcolor
,尽管我也将其包括在内。
我正在使用 pdfLaTeX 在 Overleaf 上呈现它,并且尝试在不同的编译器之间切换,但没有成功。
\documentclass[float=false,crop=true,dvipnames]{standalone}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.pathreplacing,calligraphy,3d}
\tikzset{every picture/.style={thick,
>=stealth,
decoration={calligraphic brace,
amplitude=3pt,
raise=4pt}}}
\newcommand\bs[1]{\boldsymbol{#1}}
\begin{document}
\begin{tikzpicture}[x={(10:.9cm)},y={(90:1cm)},z={(-45:.6cm)}]
\draw [->] (-1,0,0)
-- ( 0,0,0) coordinate (0_A)
-- ( 1,0,0) coordinate (P1_A)
-- ( 2,0,0) coordinate (P2_A)
-- node[sloped,above=6pt,pos=0,Peach]{$\bs{+}$}
( 3,0,0) coordinate (P3_A)
-- ( 5,0,0) node[right]{};
\fill (0_A) circle (1.5pt);
\fill (P1_A) circle (1.5pt);
\fill (P2_A) circle (1.5pt);
\fill (P3_A) circle (1.5pt);
\draw [->,ultra thick,Peach]
(2,0,0) -- (3,0,0);
\draw [decorate,pen colour={Peach},ultra thick]
(2,0,0) -- node[sloped,above=6pt,Peach]{$\bs{b}$} (3,0,0);
\draw [->,ultra thick,RoyalBlue]
(0,0,0) -- (2,0,0);
\draw [decorate,pen colour={RoyalBlue},ultra thick]
(0,0,0) -- node[sloped,above=6pt,RoyalBlue]{$\bs{a}$} (2,0,0);
\draw (0_A) circle (2.5pt);
\draw [->,ultra thick,Gray]
(0,-.05,0) -- (1,-.05,0);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\fill [RoyalBlue,opacity=.2] (0,0,0) -- (3,0,0) -- (3,0,1) --(0,0,1) -- cycle;
\draw [->] (-1,0,1)
-- ( 0,0,1) coordinate (0_B)
-- ( 1,0,1) coordinate (P1_B)
-- ( 2,0,1) coordinate (P2_B)
-- ( 3,0,1) coordinate (P3_B)
-- ( 5,0,1) node[right]{};
\fill (0_B) circle (1.5pt);
\fill (P1_B) circle (1.5pt);
\fill (P2_B) circle (1.5pt);
\fill (P3_B) circle (1.5pt);
\draw [->,ultra thick,RoyalBlue]
(0,0,1) -- (3,0,1);
\draw [decorate,decoration={mirror},pen colour={RoyalBlue},ultra thick]
(0,0,1) -- node[sloped,below=4pt,RoyalBlue]{$\bs{\;a'}$} (3,0,1);
\draw (0_B) circle (2.5pt);
\end{tikzpicture}
\end{document}
答案1
让我将我的旧评论转化为答案:
- 您需要更正颜色名称的拼写:而不是
dvipnames
正确的dvipsnames
the package
xcoloris loaded by
tikz` 包,因此您不需要再次加载它(最终会出现选项冲突的问题)- 您
\newcommand\bs[1]{\boldsymbol{#1}}
需要加载amsmath
包。相反,我会使用bm
包和命令\bn{...}
\documentclass[float=false,crop=true,dvipsnames]{standalone} % <--- correct spelling
\usepackage{tikz} % it load `xcolor` too
\usetikzlibrary{calc,
decorations.pathreplacing,
calligraphy,
3d}
\tikzset{every picture/.style={thick,
>=stealth,
decoration={calligraphic brace,
amplitude=3pt,
raise=4pt}}}
%\usepackage{amsmath}
%\newcommand\bs[1]{\boldsymbol{#1}}
\usepackage{bm} % <--- for use \bm{...} instead of `\bs{...}`,
\begin{document}
\begin{tikzpicture}[x={(10:.9cm)},y={(90:1cm)},z={(-45:.6cm)}]
\draw [->] (-1,0,0)
-- ( 0,0,0) coordinate (0_A)
-- ( 1,0,0) coordinate (P1_A)
-- ( 2,0,0) coordinate (P2_A)
-- node[sloped,above=6pt,pos=0,Peach]{$\bm{+}$}
( 3,0,0) coordinate (P3_A)
-- ( 5,0,0) node[right]{};
\fill (0_A) circle (1.5pt);
\fill (P1_A) circle (1.5pt);
\fill (P2_A) circle (1.5pt);
\fill (P3_A) circle (1.5pt);
\draw [->,ultra thick,Peach]
(2,0,0) -- (3,0,0);
\draw [decorate,pen colour={Peach},ultra thick]
(2,0,0) -- node[sloped,above=6pt,Peach]{$\bm{b}$} (3,0,0);
\draw [->,ultra thick,RoyalBlue]
(0,0,0) -- (2,0,0);
\draw [decorate,pen colour={RoyalBlue},ultra thick]
(0,0,0) -- node[sloped,above=6pt,RoyalBlue]{$\bm{a}$} (2,0,0);
\draw (0_A) circle (2.5pt);
\draw [->,ultra thick,Gray]
(0,-.05,0) -- (1,-.05,0);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\fill [RoyalBlue,opacity=.2] (0,0,0) -- (3,0,0) -- (3,0,1) --(0,0,1) -- cycle;
\draw [->] (-1,0,1)
-- ( 0,0,1) coordinate (0_B)
-- ( 1,0,1) coordinate (P1_B)
-- ( 2,0,1) coordinate (P2_B)
-- ( 3,0,1) coordinate (P3_B)
-- ( 5,0,1) node[right]{};
\fill (0_B) circle (1.5pt);
\fill (P1_B) circle (1.5pt);
\fill (P2_B) circle (1.5pt);
\fill (P3_B) circle (1.5pt);
\draw [->,ultra thick,RoyalBlue]
(0,0,1) -- (3,0,1);
\draw [decorate,decoration={mirror},pen colour={RoyalBlue},ultra thick]
(0,0,1) -- node[sloped,below=4pt,RoyalBlue]{$\bm{\;a'}$} (3,0,1);
\draw (0_B) circle (2.5pt);
\end{tikzpicture}
\end{document}
答案2
在声明中提供dvipsnames
选项\documentclass
似乎没有起到作用。如果直接在xcolor
包级别提供,则可以使用诸如Peach
等颜色,即\usepackage[dvipsnames]{xcolor}
,而不仅仅是\usepackage{xcolor}
。