EDRSPIHCRSSRSS

tikz

Difference between r1.11 and the current

@@ -42,8 +42,8 @@
}}}

* Example: 태극기
attachment:tageug.png
* tikz codes:{{{
attachment:tageug.png?width=500
* tikz codes: attachment:tikz-taegeug.tex {{{
\documentclass{standalone}

\usepackage{tikz}
@@ -122,3 +122,51 @@

\end{document}
}}}
 
 
* Example: 각도기 [[https://images.app.goo.gl/or6BhSwFYTSrg1UH6 각도기 샘플(google image)]]
attachment:tikz-protractor_ktug.png?width=500
* tikz codes: attachment:tikz-protractor_ktug.tex {{{
\documentclass[border=2mm]{standalone}
 
\usepackage{tikz}
 
\begin{document}
 
\begin{tikzpicture}[thick,font=\sffamily\large]
%% 자
\path [fill=gray!25] (-8.5,0) rectangle (8.5,-3);
\foreach \ticksA in {8,7.9,...,-8}
\draw [semithick] (\ticksA,-3) -- (\ticksA,-2.5);
\foreach \ticksB in {7.5,7,...,-7.5}
\draw (\ticksB,-3) -- (\ticksB,-2.3);
\foreach \ticksC in {8,7,...,-7}
\draw (\ticksC,-3) -- (\ticksC,-2);
\foreach \x [count=\n] in {7,6,...,-7}
\draw (\x,-1.8) node [below,rotate=180] {\n};
\draw (8,-1.8) node [below right,rotate=180,inner xsep=0pt] {mm};
%% 각도기: 배경
\path [fill=gray!25] ([shift={(190:80mm)}]0,0) arc (190:-10:80mm);
\path [fill=white] ([shift={(0:25mm)}]0,0) arc (0:180:25mm)
-- (180:55mm) arc (180:0:55mm) -- cycle;
%% 각도기: ticks
\foreach \angA in {0,1,...,180}
\draw (\angA:80mm) -- (\angA:76mm);
\foreach \angB in {0,5,...,180}
\draw (\angB:80mm) -- (\angB:73mm);
\foreach \angBx in {0,10,...,180}
\draw (\angBx:70mm) node [rotate=-90+\angBx] {\angBx};
\foreach \angC[count=\i from 0] in {180,170,...,0}
{ \draw [line width=.7mm] (\angC:60mm) -- (\angC:55mm);
\pgfmathsetmacro\xi{int(\i*10)}
% \pgfmathtruncatemacro\xi{(\i*10)} % (alternative)
\draw (\angC:63mm)
node [rotate=-90+\angC] {\xi};}
%% center
\path [fill=white] (0,0) circle (4mm);
\foreach \angR in {0,90,180,270}
\draw [line width=1mm] (\angR:5mm) -- (\angR:12mm);
\end{tikzpicture}
 
\end{document}
}}}



공주대학교 문서작성 워크숍 2017에서 집중적으로 다루었으며, 좋은 가이드북과 예제들이 많다.

  • Example: 스마일
    tikz-smile.png
    [PNG image (79.4 KB)]
    • tikz codes:
      \documentclass{standalone}
      \usepackage{tikz}
      \begin{document}
      \begin{tikzpicture}[line width=1.6pt]
      %\draw [help lines] (0,0) grid (2,2);
      \draw [fill=yellow]      (1,1) circle (1cm);
      \draw ([shift=(193:.75cm)]1,1) arc    (193:347:.75cm);
      \draw plot [domain=.15:.35]   (\x,{2/3*(\x+1)});
      \draw plot [domain=1.65:1.85] (\x,{-2/3*\x+2)});
      \filldraw (.6,1.3)  ellipse (.15cm and .25cm);
      \filldraw (1.4,1.3) ellipse (.15cm and .25cm);
      \path [fill=white] (.55,1.4)  circle (1.5pt);
      \path [fill=white] (1.35,1.4) circle (1.5pt);
      \end{tikzpicture}
      \end{document}
      
    • pstricks codes: 여기에서 가져옴.
      \documentclass[dvips]{oblivoir}
      \usepackage{pstricks-add}
      \begin{document}
      \begin{pspicture}[showgrid=false](-1,-1)(3,2)
        %\psaxes[ticks=none]{->}(-.5,-.5)(-1,-1)(2.5,3)
        \psset{linewidth=1.5pt,fillstyle=solid}
        \pscircle[fillcolor=yellow](1,1){1cm}
        \psarc[fillcolor=yellow](1,1){0.75}{193}{347}
        \psplot[algebraic]{1.65}{1.85}{-2/3*x+2}
        \psplot[algebraic]{0.15}{0.35}{2/3*(x+1)}
        \psellipse[fillcolor=black](.6,1.3)(.15,.25)
        \psellipse[fillcolor=black](1.4,1.3)(.15,.25)
        \pscircle[fillcolor=white](.55,1.4){.8mm}
        \pscircle[fillcolor=white](1.35,1.4){.8mm}
      \end{pspicture}
      \end{document}
      


  • Example: 태극기
    tageug.png
    [PNG image (42.4 KB)]
    • tikz codes: @tikz-taegeug.tex (2.22 KB)
      \documentclass{standalone}
      
      \usepackage{tikz}
      %\usepackage{xcolor}
      \definecolor{tgred}{RGB}{197,31,50}
      \definecolor{tgblue}{RGB}{33,59,116}
      
      \begin{document}
      
      \begin{tikzpicture}[scale=3]
      %% 보조선
      %\draw [help lines,step=.5] (-1.5,-1) grid (1.5,1);
      \draw [densely dashed] (-1.5,1) -- (1.5,-1);
      \draw [densely dashed] (-1.5,-1) -- (1.5,1);
      \draw [densely dashed] (0,0) circle (.75);
      
      %% 테두리
      \draw [semithick] (-1.5,-1) rectangle (1.5,1); % 3:2
      
      %% 태극
      \fill [tgred]  (0,0) circle (.5);
      \fill [tgblue] (0,0) arc (-atan(2/3):-atan(2/3)-180:1/4)
                           arc (-atan(2/3)-180:-atan(2/3):1/2) % blue
                           arc (-atan(2/3):-atan(2/3)+180:1/4) 
                           -- cycle ;
      %% 태극 (alternative)
      %\fill [tgblue] (0,0) circle (.5);
      %\fill [tgred]  (0,0) arc (-atan(2/3):-atan(2/3)-180:1/4)
      %                     arc (-atan(2/3)+180:-atan(2/3):1/2) % red
      %                     arc (-atan(2/3):-atan(2/3)+180:1/4) 
      %                     -- cycle ;
      
      %% 괘
      \begin{scope}[rotate={90-atan(2/3)}]
      \fill (-12/48,36/48) rectangle % 36/48=1/2+1/4, 12/48=.5*1/2
            (12/48,{(36+4)/48});
      \fill (-12/48,42/48) rectangle 
            (12/48,{(42+4)/48});
      \fill (-12/48,48/48) rectangle 
            (12/48,{(48+4)/48});
      \end{scope}
      
      \begin{scope}[rotate={90+atan(2/3)}]
      \fill (-12/48,36/48) rectangle 
            (12/48,{(36+4)/48});
      \fill (-12/48,42/48) rectangle 
            (-1/48,{(42+4)/48}) (1/48,42/48) rectangle %
            (12/48,{(42+4)/48});
      \fill (-12/48,48/48) rectangle 
            (12/48,{(48+4)/48});
      \end{scope}
      
      \begin{scope}[rotate={-90+atan(2/3)}]
      \fill (-12/48,36/48) rectangle 
            (-1/48,{(36+4)/48}) (1/48,36/48) rectangle %
            (12/48,{(36+4)/48});
      \fill (-12/48,42/48) rectangle 
            (12/48,{(42+4)/48});
      \fill (-12/48,48/48) rectangle 
            (-1/48,{(48+4)/48}) (1/48,48/48) rectangle %
            (12/48,{(48+4)/48});
      \end{scope}
      
      \begin{scope}[rotate={-90-atan(2/3)}]
      \fill (-12/48,36/48) rectangle 
            (-1/48,{(36+4)/48}) (1/48,36/48) rectangle %
            (12/48,{(36+4)/48});
      \fill (-12/48,42/48) rectangle 
            (-1/48,{(42+4)/48}) (1/48,42/48) rectangle %
            (12/48,{(42+4)/48});
      \fill (-12/48,48/48) rectangle 
            (-1/48,{(48+4)/48}) (1/48,48/48) rectangle %
            (12/48,{(48+4)/48});
      \end{scope}
      \end{tikzpicture}
      
      \end{document}
      



  • Example: 각도기 각도기 샘플(google image)
    tikz-protractor_ktug.png
    [PNG image (174.92 KB)]
    • tikz codes: @tikz-protractor_ktug.tex (1.47 KB)
      \documentclass[border=2mm]{standalone}
      
      \usepackage{tikz}
      
      \begin{document}
      
      \begin{tikzpicture}[thick,font=\sffamily\large]
      %% 자
      \path [fill=gray!25] (-8.5,0) rectangle (8.5,-3);
      \foreach \ticksA in {8,7.9,...,-8}
        \draw [semithick] (\ticksA,-3) -- (\ticksA,-2.5);
      \foreach \ticksB in {7.5,7,...,-7.5}
        \draw (\ticksB,-3) -- (\ticksB,-2.3);
      \foreach \ticksC in {8,7,...,-7}
        \draw (\ticksC,-3) -- (\ticksC,-2);
      \foreach \x [count=\n] in {7,6,...,-7}
        \draw (\x,-1.8) node [below,rotate=180] {\n};
      \draw (8,-1.8) node [below right,rotate=180,inner xsep=0pt] {mm};
      %% 각도기: 배경
      \path [fill=gray!25] ([shift={(190:80mm)}]0,0) arc (190:-10:80mm);
      \path [fill=white] ([shift={(0:25mm)}]0,0) arc (0:180:25mm) 
                      -- (180:55mm) arc (180:0:55mm) -- cycle; 
      %% 각도기: ticks
      \foreach \angA in {0,1,...,180}
        \draw (\angA:80mm) -- (\angA:76mm);
      \foreach \angB in {0,5,...,180}
        \draw (\angB:80mm) -- (\angB:73mm);
      \foreach \angBx in {0,10,...,180}
        \draw (\angBx:70mm) node [rotate=-90+\angBx] {\angBx};
      \foreach \angC[count=\i from 0] in {180,170,...,0}
      { \draw [line width=.7mm] (\angC:60mm) -- (\angC:55mm);
        \pgfmathsetmacro\xi{int(\i*10)}
      %  \pgfmathtruncatemacro\xi{(\i*10)} % (alternative)
        \draw (\angC:63mm)
              node [rotate=-90+\angC] {\xi};}
      %% center
      \path [fill=white] (0,0) circle (4mm);
      \foreach \angR in {0,90,180,270}
      \draw [line width=1mm] (\angR:5mm) -- (\angR:12mm);
      \end{tikzpicture}
      
      \end{document}