TeX - LaTeX Asked on August 31, 2021
Consider the following MWE
documentclass{article}
usepackage{tikz}
usetikzlibrary{decorations.pathmorphing}
begin{document}
begin{center}
begin{tikzpicture}
draw[thick] (3,-0.5)--(3,-0.8)--(0.2,-0.8)--(0.2,0.8)--(3,0.8)--(3,0.5);
draw[thick,decoration={zigzag,segment length=2mm}] decorate{(3,-0.5)--(3,0.5)};
end{tikzpicture}
end{center}
end{document}
This is the output shown by this code:
Note that the point where the zigzag and the straight lines combine doesn’t have nice finishing, as shown in this figure.
How to achieve the correct finishing??
Splitting a draw
command into two is not a good idea. Try like this:
begin{tikzpicture}
draw[thick] (3,-0.8)--(0.2,-0.8)--(0.2,0.8)--(3,0.8)--(3,0.5) decorate [decoration={zigzag,segment length=2mm}] { -- (3,-0.5)} -- cycle;
end{tikzpicture}
Correct answer by domperor on August 31, 2021
Your figure is composed of two paths and is therefore not closed, which is why there is this discontinuity.
The idea is to make a single closed path and using the options pre=lineto,pre length=5pt,post=lineto,post length=5pt
just give the coordinates of the four vertices of the rectangle.
documentclass[tikz,border=5mm]{standalone}
usetikzlibrary{decorations.pathmorphing}
begin{document}
begin{tikzpicture}
draw[thick](3,-0.8)--(0.2,-0.8)--(0.2,0.8)--(3,0.8)
decorate[decoration={zigzag,segment length=2mm,pre=lineto,pre length=5pt,post=lineto,post length=5pt}] {--cycle};
end{tikzpicture}
end{document}
Answered by AndréC on August 31, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP