KTUG 한국 텍 사용자 그룹

Menu

KTUG :: Q&A 마당

빈 항목이 들어오는 경우를 처리하기 위해 clist를 써봅니다.


\documentclass[a4paper, reqno, twoside]{amsart}

\usepackage{tikz}
\usepackage{tkz-graph}

\usepackage{expl3,xparse}

\tikzset{VertexStyle/.style = {
        shape = circle,
        fill = black,
        inner sep = 0pt,
        outer sep = 0pt,
        minimum size = 0.35em,
        line width = 0pt,
        draw}}

\ExplSyntaxOn

\cs_new:Npn \draw_my_graph:n #1
{
    \begin{tikzpicture}
    \SetGraphUnit{0.5}
    \SetVertexMath
    \tikzset{EdgeStyle/.style ={thin}}
    \Vertices[LabelOut,Lpos=90,Ldist=-0.2em,style={font=\scriptsize}]{line}{ #1 }
    \Edges ( #1 )
    \end{tikzpicture}
}

\NewDocumentCommand \LinearGraph { m }
{
    \clist_set:Nn \l_tmpa_clist { #1 }
    \clist_remove_all:Nn \l_tmpa_clist { }
    \exp_args:Nx \draw_my_graph:n { \clist_use:Nn \l_tmpa_clist {, } }
}

\ExplSyntaxOff

\begin{document}

\LinearGraph{-2,-3,,-4,-5}

\LinearGraph{-2,,-5, -6, -7, -8, -9}

\LinearGraph{1,2,3}

\LinearGraph{-5,-4,-3,-2,-1}

\LinearGraph{0,1,2,3,4,5,6,7,8,9,10,11,12,13}

\end{document}


KTUG 한국 텍 사용자 그룹