线条消失和箭头旋转错误

线条消失和箭头旋转错误

下面的 MWE 说明了这个问题(我们使用的完整序言在最后的注释中)。添加花括号修饰后,原始线条消失,其箭头移动到花括号的右端并旋转。

\documentclass[11pt]{report}
\usepackage{esvect}

\usepackage{tikz,pgfplots}
\usetikzlibrary{arrows,calc,angles,quotes}

\begin{document}

Original diagram that I am trying to add the curly braces to:

\begin{tikzpicture}
\coordinate (a) at (6,0);
\coordinate (b) at (3,0);

\draw[-triangle 45] (0,0) -- ($(a)+(b)$) node[right,below,xshift=-1.5cm] {$\vv{a+b}$};
\draw[-triangle 45,blue] (0,0) -- (a) node[midway,below,xshift=1.5cm] {$\vv{a}$};
\draw[-triangle 45,red] (0,0) -- (b) node[midway,below] {$\vv{b}$};
\end{tikzpicture}

This looks a bit confusing as the labels look as they apply to the wrong sections of the vectors and their sum.

This demonstrates the issue with the arrow heads after adding the curly braces and staggering the labels along Y axis:

\begin{tikzpicture}
\coordinate (a) at (6,0);
\coordinate (b) at (3,0);

\draw[-triangle 45,decoration={brace,mirror,raise=1.5cm},decorate] (0,0) -- ($(a)+(b)$) node[midway,below=1.5cm] {$\vv{a+b}$};
\draw[-triangle 45,blue,decoration={brace,mirror,raise=1cm},decorate] (0,0) -- (a) node[midway,below=1cm] {$\vv{a}$};
\draw[-triangle 45,red,decoration={brace,mirror,raise=0.5cm},decorate] (0,0) -- (b) node[midway,below=0.5cm] {$\vv{b}$};
\end{tikzpicture}

The vector lines are gone and the arrow heads are at what looks like 30-45 degree angle.

\end{document}

% The original document's full preamble:

%\documentclass[11pt]{report}
%\usepackage[utf8]{inputenc}
%\usepackage[T1]{fontenc}
%\usepackage[top=1in, bottom=1in, left=1in, right=1in]{geometry}
%\usepackage{xcolor}
%\usepackage{xstring}
%\usepackage{gensymb}
%\usepackage{amssymb}
%\usepackage{esvect}
%\usepackage{siunitx}
%\usepackage{braket}
%\usepackage{mathtools}
%\everymath{\displaystyle}
%
%\usepackage{tikz,pgfplots}
%\usepgflibrary{intersections}
%\usetikzlibrary{arrows,calc,angles,quotes}
%\pgfplotsset{compat=newest}

在此处输入图片描述

通过交错排列矢量本身而不添加括号,可以暂时解决演示问题,但仍然希望彻底解决它。

答案1

将路径修饰为postaction

\draw
  [-triangle 45]
  [postaction={decoration={brace,mirror,raise=1.5cm},decorate,draw,-}]
  (0,0) -- ($(a)+(b)$) node[midway,below=1.5cm] {$\vv{a+b}$};

但我会用scope

\documentclass[11pt]{report}
\usepackage{esvect}

\usepackage{tikz}
\usetikzlibrary{arrows,calc,
    decorations.pathreplacing% for the brace decoration
}

\begin{document}

\begin{tikzpicture}
\coordinate (a) at (6,0);
\coordinate (b) at (3,0);

\begin{scope}[
    -triangle 45,
    mybrace/.style={postaction={decoration={brace,mirror,raise=#1},decorate,draw,-}}
  ]
  \draw[mybrace=1.5cm] (0,0) -- ($(a)+(b)$) node[midway,below=1.5cm] {$\vv{a+b}$};
  \draw[blue,mybrace=1cm] (0,0) -- (a) node[midway,below=1cm] {$\vv{a}$};
  \draw[red,mybrace=.5cm] (0,0) -- (b) node[midway,below=0.5cm] {$\vv{b}$};
\end{scope}
\end{tikzpicture}

\end{document}

结果:

在此处输入图片描述

相关内容