0

I moved my perfectly fine tikzpicture into an external file on its own. But rendering it as a standalone document seems to disregard the xcolor package, even though I included that as well.

I'm rendering this on Overleaf with pdfLaTeX, and I have tried switching between the different compilers, although without luck.

\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}
3
  • Where is defined \bs?
    – Zarko
    Feb 13, 2020 at 0:39
  • In my main document, sorry. But it wouldn't have an influence on the colours – only that my vector names would'nt be bold. Thanks nevertheless :P
    – Matt
    Feb 13, 2020 at 0:42
  • 1
    ok, the same result you will obtain with \documentclass[tikz, dvipsnames]{standalone}, removing xcolor (it is loaded by tikz) and tikz from preamble and after adding usepackage{bm} to preamble instead of \bs (as shortenes for \boldsymbol) use \bm.
    – Zarko
    Feb 13, 2020 at 0:55

2 Answers 2

1

Let me turn my old comment to an answer:

  • you need to correct spel color names: instead of dvipnames is correct dvipsnames
  • the package xcoloris loaded bytikz` package, so you not need to load it again (and eventually have problems with options clash)
  • for your \newcommand\bs[1]{\boldsymbol{#1}} you need to load amsmath package. Instead it I would use the bm package and comand \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}

enter image description here

1
  • Sorry, I took forever to return to this site. Marked yours as the answer. :)
    – Matt
    Nov 13, 2020 at 15:14
1

Providing dvipsnames as an option in the \documentclass declaration does not seem to be doing the trick. If you provide it directly at the xcolor package level, you can use colors like Peach etc. i.e. \usepackage[dvipsnames]{xcolor}, instead of just \usepackage{xcolor}.

2
  • Wait, it worked? - I misspelled dvipsnames as dvipnames (without the s).
    – Matt
    Feb 12, 2020 at 23:29
  • 1
    As it turns out, I could move it back up in the documentclass declaration. As long as I spell it correctly! ^^;
    – Matt
    Feb 12, 2020 at 23:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .