问题:在下面MWE
,我只想更改每一行的箭头样式(以所有可能的方式)。
梅威瑟:
\documentclass[12pt]{article}
\usepackage{pgf}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}
\usetikzlibrary{decorations.markings}
\begin{document}
\LARGE
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
\draw [line width=0.3pt] (0,0)-- (0,4);
\draw [line width=0.3pt] (0,0)-- (4,0);
\draw [line width=0.3pt] (0,4)-- (4,4);
\draw [line width=0.3pt] (4,4)-- (4,0);
\draw [line width=0.3pt] (4,0)-- (10,0);
\draw [line width=0.3pt] (10,0)-- (10,4);
\draw [line width=0.3pt] (10,4)-- (7,2);
\begin{scope}[very thick,decoration={
markings,
mark=at position 0.5 with {\arrow{>}}}
]
\draw [line width=0.3pt,postaction={decorate}] (0,0)-- (0,4);
%\draw [line width=1pt,postaction={decorate}] (0,0)-- (4,4);(this command create arrow with line segment)
\draw [line width=0.3pt,postaction={decorate}] (4,4)-- (0,4);
\draw [line width=0.3pt,postaction={decorate}] (4,0)-- (0,0);
\draw [line width=0.3pt,postaction={decorate}] (4,0)-- (10,0);
\draw [line width=0.3pt,postaction={decorate}] (10,0)-- (10,4);
\draw [line width=0.3pt,postaction={decorate}] (7,2)-- (10,4);
\end{scope}
\begin{scriptsize}
\draw [fill=black] (0,0) circle (2pt);
\draw[color=black] (-0.0437,-0.42) node {$V_2$};
\draw [fill=black] (0,4) circle (2.5pt);
\draw[color=black] (-0.0437,4.4) node {$V_1$};
\draw [fill=black] (4,0) circle (2.5pt);
\draw[color=black] (3.97592,-0.42) node {$V_3$};
\draw [fill=black] (4,4) circle (2.5pt);
\draw[color=black] (3.97592,4.4) node {$V_4$};
\draw [fill=black] (10,0) circle (2.5pt);
\draw[color=black] (9.96542,-0.42) node {$V_5$};
\draw [fill=black] (10,4) circle (2.5pt);
\draw[color=black] (9.96542,4.42) node {$V_6$};
\draw [fill=black] (7,2) circle (2.5pt);
\draw[color=black] (6.93074,1.60589) node {$V_7$};
\end{scriptsize}
\end{tikzpicture}
\end{document}
答案1
如果我理解得没错,你想彻底改变箭头的风格。
您可以定义一种样式(例如myar
),然后如果您更改该样式,您将同时更改所有箭头。
我还使用 TikZ 矩阵简化了您的代码。
\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{matrix}
\tikzset{
myar/.style={
line cap=round,
line join=round,
>=triangle 45,
decoration={
markings,
mark=at position 0.5 with {\arrow{>}}
},
postaction={decorate},
line width=.5pt,
},
myline/.style={
line width=.5
pt,
}
}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}
\matrix[
matrix of nodes,
row sep=1.63cm,
column sep=2.6cm,
nodes={draw, circle, fill=black, minimum width=5pt,inner sep=0pt, font=\scriptsize}
] (mymatr) {
|[label=$V_1$]| &[1cm] |[label=$V_4$]| && |[label=$V_6$]| \\
&& |[label=below:$V_7$]| \\
|[label=below:$V_2$]| & |[label=below:$V_3$]| && |[label=below:$V_5$]| \\
};
\draw [myar] (mymatr-1-2) -- (mymatr-1-1);
\draw [myar] (mymatr-3-1) -- (mymatr-1-1);
\draw [myar] (mymatr-3-2) -- (mymatr-3-1);
\draw [myar] (mymatr-3-2) -- (mymatr-3-4);
\draw [myar] (mymatr-3-4) -- (mymatr-1-4);
\draw [myar] (mymatr-2-3) -- (mymatr-1-4);
\draw [myline] (mymatr-3-2) -- (mymatr-1-2);
\end{tikzpicture}
\end{document}