有人能帮我吗?东北线和西北线没有像我想象的那样工作,因为它只显示了很多小线。我发现这个解决方法非常有效。唯一的问题是我需要东南线之间的间隙与水平线相同。我试过调整这些值,但找不到我需要的。任何帮助都很好 :D
我有一定的乳胶知识,所以越简单越好:D
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{sectsty}
\usepackage{titlesec}
\usetikzlibrary{patterns}
\pgfdeclarepatternformonly{south west lines}{\pgfqpoint{-0pt}{-0pt}}{\pgfqpoint{3pt}{3pt}}{\pgfqpoint{3pt}{3pt}}{
\pgfsetlinewidth{0.4pt}
\pgfpathmoveto{\pgfqpoint{0pt}{0pt}}
\pgfpathlineto{\pgfqpoint{3pt}{3pt}}
\pgfpathmoveto{\pgfqpoint{2.8pt}{-0.2pt}}
\pgfpathlineto{\pgfqpoint{3.2pt}{.2pt}}
\pgfpathmoveto{\pgfqpoint{-.2pt}{2.8pt}}
\pgfpathlineto{\pgfqpoint{.2pt}{3.2pt}}
\pgfusepath{stroke}}
\pgfdeclarepatternformonly{south east lines}{\pgfqpoint{-0pt}{-0pt}}{\pgfqpoint{3pt}{3pt}}{\pgfqpoint{3pt}{3pt}}{
\pgfsetlinewidth{0.4pt}
\pgfpathmoveto{\pgfqpoint{0pt}{3pt}}
\pgfpathlineto{\pgfqpoint{3pt}{0pt}}
\pgfpathmoveto{\pgfqpoint{.2pt}{-.2pt}}
\pgfpathlineto{\pgfqpoint{-.2pt}{.2pt}}
\pgfpathmoveto{\pgfqpoint{3.2pt}{2.8pt}}
\pgfpathlineto{\pgfqpoint{2.8pt}{3.2pt}}
\pgfusepath{stroke}}
\begin{document}
\begin{tikzpicture}
\draw [pattern=south west lines, pattern color=red] (0,0)--(0,1)--(1,1)--(1,0)--cycle;
\end{tikzpicture}
\begin{tikzpicture}
\draw [pattern=horizontal lines, pattern color=red] (0,0)--(0,1)--(1,1)--(1,0)--cycle;
\end{tikzpicture}
\end{document}
答案1
如果你使用patterns.meta
,事情就会变得容易得多。你只需distance
在行间设置,然后设置它们的angle
。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{patterns.meta}
\begin{document}
\begin{tikzpicture}
\draw [pattern={Lines[angle=45,distance=4pt]},pattern color=red]
(0,0) rectangle (1,1);
\end{tikzpicture}
\begin{tikzpicture}
\draw [pattern={Lines[angle=0,distance=4pt]},pattern color=red]
(0,0) rectangle (1,1);
\end{tikzpicture}
\end{document}