Share
Embed
Ti𝑘Z入門
L
October 23, 2020
Transcript
22 slides
-
TikZ ͱ ▶ TikZ TikZ ist kein Zeichenprogramm (υΠπޠͰʮTikZ
ඳըϓϩάϥ ϜͰ͋Γ·ͤΜʯ) ͷུ 1(࠶ؼత಄ࣈޠ) ▶ Till Tantau ࢯʹΑΔ L A TEX ͷඳըػೳ ▶ picture ڥͷΑ͏ʹը૾ϑΝΠϧΛஔ͢ΔͷͰͳ͘ɼඳը͢Δ 1ެࣜϚχϡΞϧΑΓɽ ʮϓϩάϥϜͱ͍͏ΑΓݴޠʯͱ͍͏͜ͱΒ͍͠ɽެࣜϚχϡΞϧ ίϯιʔϧ্Ͱ”texdoc tikz” ͱଧͯදࣔ͞ΕΔɽ 2/22 -
͍ํ % p d f ग़ ྗ ͢ Δ ͱ
͖ Φ ϓ γ ϣ ϯ Λ Ճ ͑ Δ \documentclass [dvipdfmx ]{ jsarticle} % t i k z ύ ο έ ʔ δ Λ ಡ Έ ࠐ Ή \usepackage {tikz} % ඞ ཁ ʹ Ԡ ͡ ͯ ֦ ு ϥ Π ϒ ϥ Ϧ Λ ಡ Έ ࠐ Ή \usetikzlibrary { intersections , calc , arrows} \begin{document} % 1 ߦ ͷ ඳ ը ॲ ཧ \tikz\draw (0 ,0) - -(1 ,1); % ෳ ߦ ͷ ඳ ը ॲ ཧ ( f i g u r e ڥ Ͱ ͞ Β ʹ ғ Μ Ͱ ͍ ͍ ) \begin{ tikzpicture } \draw (0 ,0) - -(1 ,1); \draw (0 ,1) - -(1 ,0); \end{ tikzpicture } \end{document} ͲΜͳॲཧͰ࠷ޙʹηϛίϩϯΛ͚ͭΔɽ ࠲ඪͷࢦఆ (x,y) (্͕+y, ӈ͕+x) ·ͨۃ࠲ඪܗࣜ (֯:͞) 3/22 -
୯७ͳઢ \tikz\draw (0 ,0) - -(1 ,1) - -(2 ,0);
ઢͷͷ࠲ඪΛ--Ͱͭͳ͍Ͱॻ͍͍ͯ͘ɽ \tikz\draw (0,0)--(1,1)--(2,0)-- cycle; cycle ͰऴΘΔͱऴͱ࢝Λͭͳ͍Ͱดͯ͘͡ΕΔɽ \tikz\draw[line width =2, rounded corners =5](0 ,0) - -(1 ,1) - -(2 ,0); ઢͷଠ͞ɼ֯ͷؙΈͳͲΛௐՄೳɽ࠶ͼઑΒͤΔʹ sharp cornersɽ 4/22 -
ઢͷଠ͞ɾೋॏઢ \begin{ tikzpicture } \draw[line width =1pt](0 ,0) - -(2
,0); \draw[line width =1mm](0 , -0.5) - -(2 , -0.5); \draw[ultra thin ](0,-1)--(2,-1); \draw[very thin ](0 , -1.5) - -(2 , -1.5); \draw[thin ](0,-2)--(2,-2); \draw[semithick ](0 , -2.5) - -(2 , -2.5); \draw[thick ](0,-3)--(2,-3); \draw[very thick ](0 , -3.5) - -(2 , -3.5); \draw[ultra thick ](0,-4)--(2,-4); \draw[double ](0 , -4.5) - -(2 , -4.5); \draw[double=red ](0,-5)--(2,-5); \draw[double distance =2pt](0 , -5.5) - -(2 , -5.5); \draw[line width =1mm , opacity =.6](0 , -6) - -(2 , -6); \end{ tikzpicture } 5/22 -
ഁઢ \begin{ tikzpicture }[ line width =1] % ڞ ௨
͢ Δ Φ ϓ γ ϣ ϯ ͜ ͜ ʹ ॻ ͚ Δ \draw[dotted ](0 ,3) - -(2 ,3); \draw[dashed ](0 ,2.5) - -(2 ,2.5); \draw[dash dot ](0 ,2) - -(2 ,2); \draw[dash dot dot ](0 ,1.5) - -(2 ,1.5); \draw[densely dotted ](0 ,1) - -(2 ,1); \draw[loosely dotted ](0 ,0.5) - -(2 ,0.5); \draw[dash pattern=on 3pt off 2pt on 5pt off 2pt ](0 ,0) - -(2 ,0); \end{ tikzpicture } 6/22 -
ҹͷܗঢ় \begin{ tikzpicture }[ line width =1] \draw [ -
>](0 ,3.5) - -(1 ,3.5); \draw [ < -](0 ,3) - -(1 ,3); \draw [ < - >](0 ,2.5) - -(1 ,2.5); \draw [->>](0,2)--(1,2); \draw[->,>=to ](0 ,1.5) - -(1 ,1.5); \draw[->,>=latex ](0 ,1) - -(1 ,1); \draw[<-,>= stealth ](0 ,0.5) - -(1 ,0.5); \draw[stealth -latex ](0 ,0) - -(1 ,0); \end{ tikzpicture } tikzpicture ڥͷΦϓγϣϯʹ [>=stealth] ͳͲͱઃఆ͢Δ͜ͱͰ͖Δɽ 7/22 -
ʹऍ \begin{ tikzpicture }[ line width =1] \draw (0 ,
-0.5) node[left ]{ ࢝ } - -(0.5 , -0.5) node[below ]{$\pi$} --(1,-0.5) node[right ]{ \hbox{\tate ऴ }}; \end{ tikzpicture } ࢝ π ऴ ࠲ඪͷޙʹ node[Ґஔ]{จࣈྻ} ͱॻ͘ͱͦͷҐஔʹจࣈྻΛදࣔͰ͖Δɽ Ґஔ above,left,below,right,above left ͳͲɽ จࣈྻࣜ L A TEX ຊจͰ͑ΔͷͳΒେମࢦఆͰ͖Δɽ 8/22 -
ํܗɾਨઢ \begin{ tikzpicture } \draw (0 ,1.5) rectangle (2 ,2);
\draw[rounded corners =5](0 ,0) rectangle (2 ,1); \end{ tikzpicture } ର֯ઢͷ࠲ඪΛࢦఆ͢Δɽ\draw ͷΦϓγϣϯ͍ΖΜͳͷʹྲྀ༻Մೳɽ \begin{ tikzpicture } \draw (0 ,0.5)| -(1 ,1); \draw (0 ,0) -|(1 ,0.5); \draw (2,1)--($(0 ,0)!(2 ,1)!(1 ,0)$); \end{ tikzpicture } $(a,b)!(x,y)!(c,d)$ Ͱ (x,y) ͔Β (a,b),(c,d) Λ݁ͿઢʹԼΖͨ͠ਨઢͷ ͕ٻ·Δɽ 9/22 -
֨ࢠɾԁɾପԁ \begin{ tikzpicture } \draw[step=1,gray ]( -0.2 , -0.2) grid
(2.2 ,2.2); \draw (0.5 ,0.5) circle (0.5) node{$\pi r^2$}; \draw (1 ,1.5) ellipse (1 and 0.5); \draw (1.5 ,0.5) circle[x radius =0.6 , y radius =0.3 , rotate =45]; \end{ tikzpicture } πr2 \draw[step=֨ࢠִؒ](ࠨԼ)grid(ӈ্) Ͱ֨ࢠɽ (த৺࠲ඪ)circle(ܘ) Ͱԁɽ (த৺࠲ඪ)ellipse(x ܘ and y ܘ) Ͱପԁɽ (த৺࠲ඪ)circle[x radius=,y radius=,rotate=] Ͱପԁɽ 10/22 -
৭ ৭ xcolor.sty Ͱఆٛ͞Ε͍ͯΔ͕ɼTikZ ΛಡΈࠐΊ xcolor ಡΈࠐ·ΕΔɽ ▶ RGB ܥ
: red, green, blue, brown, lime, orange, pink, purple, teal, violet ▶ CMYK ܥ : cyan, magenta, yellow, olive ▶ gray ܥ : black, darkgray, gray, lightgray, white ▶ black!20 Ͱࠇ 20%ɼred!30!yellow Ͱ 30%ԫ 70% ͳͲɽ ▶ definecolor ίϚϯυͰ৭Λࣗ࡞͢Δ͜ͱͰ͖Δɽ 11/22 -
ృΓͭͿ͠ \begin{ tikzpicture } \fill[teal ](0 ,0) - -(1.5 ,0)
- -(1 ,1); \fill[olive ](0 , -0.25) rectangle (1.5 , -0.75); \filldraw[fill=violet ,very thick ](1.75 ,0) circle (0.5); \filldraw[fill=pink ,very thick] (0 ,-1.5)--(0.5,-1)--(1,-2) - -(1.5 , -1.5); \end{ tikzpicture } Լʹॻ͍ͨͷ΄Ͳલ໘ʹදࣔ͞ΕΔɽ ด͍ͯ͡ͳͯ࢝͘ͱऴΛͭͳ͍ͩྖҬͰృͬͯ͘ΕΔɽ 12/22 -
Ҡಈɾ֦ॖɾճస \begin{ tikzpicture }[ ultra thick] \draw[->,>=stealth ,semithick] ( -0.5
,0) - -(2.5 ,0) node[above ]{$x$}; \draw[->,>=stealth ,semithick] (0 , -0.5) - -(0 ,3.5) node[right ]{$y$}; \draw[red ](0 ,0.5) - -(0.5 ,0) - -(1 ,0.5); \draw[shift ={(1 ,2)} , blue ](0 ,0.5) - -(0.5 ,0) - -(1 ,0.5); \draw[scale =2,blue ](0 ,0.5) - -(0.5 ,0) - -(1 ,0.5); \draw[rotate =-70, blue ](0 ,0.5) - -(0.5 ,0) - -(1 ,0.5); \end{ tikzpicture } x y σϑΥϧτͰݪΛத৺ʹ֦ॖɼճస͕ߦΘΕΔɽ [scale around={2:(1,1)}] ͱ͢Δͱ (1,1) Λத৺ʹ 2 ഒʹ֦େ͞Εɼ [rotate around={20,(1,1)}] ͱ͢Δͱ (1,1) Λத৺ʹ࣌ܭճΓʹ 20˃ճస ͢Δɽ 13/22 -
ΛจࣈͰஔ͘ \begin{ tikzpicture }[ ultra thick] \coordinate (A) at (1
,1); \coordinate [label = -90:B] (B) at (2 ,1); \coordinate [label=right:C] (C) at (3 ,1); \draw (A)--(B)--(C); \end{ tikzpicture } B C [label=ภ֯:ද໊ࣔ],[label=Ґஔ:ද໊ࣔ] ͱ͢Δͱද໊ࣔಉ࣌ʹઃఆͰ ͖Δɽ 14/22 -
ަͷࣗಈܭࢉ \begin{ tikzpicture }[ scale =0.5] \draw[name path=C1] (0 ,0)
circle (1); \draw[name path=C2] (2 ,1) circle (2); \path[name intersections ={of= C1 and C2 , by={A,B }}]; \fill[red] (A) circle (0.06) node[above left ]{A}; \fill[red] (B) circle (0.06) node[below ]{B}; \end{ tikzpicture } A B 15/22 -
࠲ඪܭࢉ \begin{ tikzpicture }[ scale =0.4] \coordinate (A) at (1
,1); \coordinate (B) at (5 ,1); \fill (A)circle (0.1) node[below ]{A}; \fill (B)circle (0.1) node[below ]{B}; \fill ($(A)!0.7!(B)$)circle (0.1) node[below ]{C}; \fill ($(A)! -0.3!(B)$)circle (0.1)[ left]node{D}; \fill ($(A)!1 cm!(B)$)circle (0.1)[ above]node{E}; \fill ($(A)!0.7!30:(B)$)circle (0.1)[ above]node{F}; \end{ tikzpicture } A B C D E F $(A)!t!(B)$ AɼB ͔Βͷڑͷൺ͕ |t|: |1 − t| ͷ AB ্ͷɽ $(A)!t!:a(B)$ͦΕΛ a ࣌ܭճΓʹ A Λத৺ʹճసͤͨ͞ɽ $(A)!t cm:a(B)$ A ͔Β B ͖ʹ t cm ʹ͋Δɽ $(A)+(B)$,$k*(A)$ͱ͍͏ɼੵܭࢉՄೳɽ 16/22 -
܁Γฦ͠ \begin{ tikzpicture }[ scale =0.1] \draw (0 ,0) -
-(100 ,0); \foreach \x in {0 ,... ,100} \draw (\x ,0)--(\x ,3); \foreach \x in {0 ,5 ,... ,100} \draw (\x ,0)--(\x ,5); \foreach \x in {0 ,10 ,... ,100} \draw (\x ,0)--(\x ,7); \end{ tikzpicture } ΠςϨʔλͷ૿͑ํࣗಈͰྨਪͯ͘͠ΕΔɽ \x in {A,B,...,Z}ͱ͢Δͱ x ʹ A ͔Β Z ·ͰͷΞϧϑΝϕοτ͕ೖΔɽ 17/22 -
άϥϑ (ؔ) \begin{ tikzpicture }[ scale =0.5] \draw[samples =300 ,
% ϓ ϩ ο τ domain =-3*pi /4:3* pi/4, % ൣ ғ variable=\t] % ม ໊ plot(\t ,{ sin (2* \t r)}) node[below ]{ \tiny $y=\sin x$ \normalsize }; \end{ tikzpicture } y = sin x ࠲ඪͷܭࢉࣜʹ () Λ͏ͳΒ{}ͰғΉɽ ࡾ֯വ r Λࢦఆ͢ΔͱϥδΞϯͰ͕֯ࢦఆͰ͖Δɽ cos,exp,sqrt ͳͲ͑Δɽ 18/22 -
άϥϑ (άϥϑཧ) \begin{ tikzpicture }[ line width =1.6pt ,node distance
=2 cm] \node(a) [draw ,circle ]{$a$}; \node[above right of=a](b) [draw ,circle ]{$b$}; \node[below right of=a](c) [draw ,circle ]{$c$}; \node[right of=a,node distance =2.82 cm](d) [draw , circle ]{$d$}; \draw(a) to[bend left] node[midway ,left] {$e_1$}(b ); \draw(a) -- node[midway ,right ]{$e_2$}(b); \draw(a) -- node[midway ,right ]{$e_3$}(c); \draw(a) to[bend right] node[midway ,left] {$e_4$}( c); \draw(a) -- node[pos =.7, above ]{$e_5$}(d); \draw(b) -- node[midway ,above ]{$e_6$}(d); \draw(c) -- node[midway ,below ]{$e_7$}(d); \end{ tikzpicture } a b c d e1 e2 e3 e4 e5 e6 e7 bend left/right ઢͷਐߦํʹରͯ͠ӈ͔ࠨ͔ɽ 19/22 -
ͦͷଞ ▶ tikzpicture ڥͷ࠷ॳʹ\clip(x,y)rectangle(z,w); ͱॻ͘ͱͦͷ ํܗͷத͚ͩʹඳը͞ΕΔɽ ▶ \draw(a,b)arc(s:t:r); ͱ͢Δͱத৺ (a,b)
ܘ r ͷԁͷภ֯ s˃͔Β t˃ ͷހΛඳ͚Δɽ etc. 20/22 -
ࢀߟจݙ ▶ TikZ ֮ॻ ˡ ຊޠͰମܥతʹ·ͱ·͍͔ͬͯͯΓ͍͢ɽ http://perikanfan.web.fc2.com/Manual.pdf ▶ TikZ ͷ͍ํ
(ݍฤ) http://alg-d.com/math/kan_extension/TikZ_for_cat.pdf ▶ TEXWiki TikZ https://texwiki.texjp.org/?TikZ ▶ TikZ ΛͬͯΈΑ͏ʂ: جຊతͳ͍ํ https://guides.lib.kyushu-u.ac.jp/c.php?g=774891&p=5559091 ▶ LaTeX ͰਤΛඳ͚Δ TikZ ͷ͍ํ https://math-note.xyz/latex/tikz/tikz-line/ ▶ TikZ ͰϊʔυΛ૬ରҐஔͰஔ͢Δ https://zrbabbler.hatenablog.com/entry/20150201/1422745097 ▶ Ԟଜɾࠇ༞հʰL A TEX2ε ඒจॻ࡞ೖʱ(ٕज़ධࣾɼ1997) 22/22