鉴于此序言:
\documentclass{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage{mathtools}
\usepackage{tikz}
\setdefaultlanguage{italian}
\usetikzlibrary{patterns}
我尝试编译(XeLaTeX)这张 TikZ 图片:
\begin{document}
\begin{tikzpicture}[line width=0.5pt, >=latex, scale=2]
\coordinate (O) at (0,0);
\path (O)++(0,4) coordinate ["left:$y$"] (y);
\draw [-stealth, thin] (O)--++(4,0) coordinate ["below:$x$"] (x);
\draw [stealth- , thin](y) -- (O);
\draw [thin] (-0.5,0) -| (0,-0.5);
\coordinate (v1) at (1.5,2);
\path (2,0.5) coordinate (v2) ++(v1) coordinate (I);
\path [pattern=north west lines, pattern color=red] (O)--(v1)--(I)--(v2)--(O);
\draw [->] (O)--(v1); \draw [dashed, ->] (v1)--(I);
\draw [->] (O)--(v2); \draw [dashed, ->] (v2)--(I);
\node [anchor=north west, font=\footnotesize] at (v2) {${
\begin{bmatrix}
a_{12} \\ a_{22}
\end{bmatrix}
}$};
\node [anchor=south east, font=\footnotesize] at (v1) {${
\begin{bmatrix}
a_{11} \\ a_{21}
\end{bmatrix}
}$};
\end{tikzpicture}
\end{document}
但我收到以下错误:
./submit tex stack.tex:14: Package pgfkeys Error: I do not know the key '/tikz/"left:$y$"' and I am going to ignore it. Perhaps you misspelled it.
我认为这是由于 polyglossia 处理意大利语中的“ ”的方式造成的。我尝试通过切换到以下方式来摆脱它:
\setdefaultlanguage[babelshorthands=true]{italian}
但之后我无法编译(实际上,GUI 中的齿轮不会停止),所以我没有收到任何报告。这是错误还是我做错了什么?
答案1
您使用的语法也需要该quotes
库。您还应该加载该babel
库。
\documentclass{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{patterns,quotes,babel}
\setdefaultlanguage{italian}
\begin{document}
\begin{tikzpicture}[line width=0.5pt, >=latex, scale=2]
\coordinate (O) at (0,0);
\path (O)++(0,4) coordinate ["left:$y$"] (y);
\draw [-stealth, thin] (O)--++(4,0) coordinate ["below:$x$"] (x);
\draw [stealth- , thin](y) -- (O);
\draw [thin] (-0.5,0) -| (0,-0.5);
\coordinate (v1) at (1.5,2);
\path (2,0.5) coordinate (v2) ++(v1) coordinate (I);
\path [pattern=north west lines, pattern color=red] (O)--(v1)--(I)--(v2)--(O);
\draw [->] (O)--(v1); \draw [dashed, ->] (v1)--(I);
\draw [->] (O)--(v2); \draw [dashed, ->] (v2)--(I);
\node [anchor=north west, font=\footnotesize] at (v2) {${
\begin{bmatrix}
a_{12} \\ a_{22}
\end{bmatrix}
}$};
\node [anchor=south east, font=\footnotesize] at (v1) {${
\begin{bmatrix}
a_{11} \\ a_{21}
\end{bmatrix}
}$};
\end{tikzpicture}
\end{document}