I am looking for a tex environment which allows me to label text like this: enter image description here Since the word 'label' is already occupied I don't know how to google for a solution. Does anyone have an idea? Maybe there is a tikz solution?


One can define a simple macro for this

        \node[inner xsep=0pt,inner ysep=1pt,red] (a) {#1};
        \draw[red] (a.south west)--(a.south east);
        \coordinate (a1) at (a.south);
        \node[inner xsep=0pt,right=0pt of a] (b) {#2};
        \node[inner xsep=0pt,inner ysep=1pt,right=0pt of b,green!50!black] (c) {#3};
        \draw[green!50!black] (c.south west)--(c.south east);
        \coordinate (c1) at (c.south);
        \draw[red] ($(a1)+(-110:0.1)$)--($(a1)+(-110:1)$) node[fill=white,font=\tiny\sffamily,inner sep=2pt] {Some text};
        \draw[green!50!black] ($(c1)+(-70:0.1)$)--($(c1)+(-70:1)$) node[fill=white,font=\tiny\sffamily,inner sep=2pt] {Hello world};



enter image description here

  • Thank you very much for your answer! This looks great so far. But is also a more generic solution possible? I think of n labeled parts to which I can pass individual colors and description texts? Probably, my question wasn't formulated clear enough...
    – lukasl1991
    Mar 19 '19 at 17:55
  • @lukasl1991 In fact, I don't think you really need a macro. It is just a centered TikZ picture, and looking at my code I think you can do for yourself.
    – user156344
    Mar 20 '19 at 1:44
  • Yeah, maybe you're right. Thanks!
    – lukasl1991
    Mar 20 '19 at 7:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.