Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a sentence like this "पठ् + अ + ति" and I want to add some notes like shown in the attached image. Is there a package for such things or I need to work with Tikz.

Any reference material or help would be appreciated.

enter image description here

============Edited question based on Solution given by Gonzolo =========== Here is MWE and the output I am getting.

\documentclass{article}
\usepackage{fontspec,xltxtra,xunicode}
\usepackage{tikz}
\usetikzlibrary{shapes.callouts}
\setmainfont[Script=Devanagari,AutoFakeBold=3.5]{Sanskrit 2003}
\definecolor{myblue}{RGB}{122,175,234}

\newcommand\tikzmark[1]{%
  \tikz[remember picture,overlay]\node (#1) {};}
\newcommand\MyNote[3][]{%
\begin{tikzpicture}[remember picture,overlay]
\node[rectangle callout, fill=myblue,text width=2cm,align=center,font=\sffamily\bfseries\color{white},#1] at #2 {#3}; 
\end{tikzpicture}%
}

\begin{document}

पठ् \tikzmark{a}\qquad + अ + \tikzmark{b} ति ।

\MyNote[callout relative pointer={(0,1)}]{([yshift=-1.5cm]a)}{क्रिया को धारण करता है वह धातु है ।}
\MyNote[callout relative pointer={(0,1)}]{([yshift=-1.5cm]b)}{"अ \& ति" का कर्ता अर्थ को कह रहा है}

\end{document}

Output of above MWE

share|improve this question
    
Aside, content-related (not TeX-related): the whole word पठति is the verb, the पठ् part of it is more properly called the verbal root, or dhātu. –  ShreevatsaR Sep 29 '13 at 0:27
add comment

2 Answers

up vote 12 down vote accepted

You can use the shapes.callouts library from TikZ:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.callouts}

\definecolor{myblue}{RGB}{122,175,234}

\newcommand\tikzmark[1]{%
  \tikz[remember picture,overlay]\node (#1) {};}
\newcommand\MyNote[3][]{%
\begin{tikzpicture}[remember picture,overlay]
\node[rectangle callout, fill=myblue,text width=2cm,align=center,font=\sffamily\bfseries\color{white},#1] at #2 {#3}; 
\end{tikzpicture}%
}

\begin{document}

Some \tikzmark{a}text\qquad Some other\tikzmark{b} text

\MyNote[callout relative pointer={(0,1)}]{([yshift=-1.5cm]a)}{some note for the first text}
\MyNote[callout relative pointer={(0,1)}]{([yshift=-1.5cm]b)}{some note for the second text}

\end{document}

enter image description here

For details, please see Section *48.7 Callout Shapes*in the PGF manual.

With the Sanskrit 2003 font used, \sffamily must be removed from the font attributes:

\documentclass{article}
\usepackage{fontspec,xunicode}
\usepackage{tikz}
\usetikzlibrary{shapes.callouts}
\setmainfont[Script=Devanagari,AutoFakeBold=3.5]{Sanskrit 2003}
\definecolor{myblue}{RGB}{122,175,234}

\newcommand\tikzmark[1]{%
  \tikz[remember picture,overlay]\node (#1) {};}
\newcommand\MyNote[3][]{%
\begin{tikzpicture}[remember picture,overlay]
\node[rectangle callout, fill=myblue,text width=2cm,align=center,font=\color{white},#1] at #2 {#3}; 
\end{tikzpicture}%
}

\begin{document}

पठ् \tikzmark{a}\qquad + अ + \tikzmark{b} ति ।

\MyNote[callout relative pointer={(0.6,1)}]{([yshift=-1.65cm,xshift=-1cm]a)}{क्रिया को धारण करता है वह धातु है ।}
\MyNote[callout relative pointer={(-0.5,1)}]{([yshift=-1.65cm,xshift=0.65cm]b)}{"अ \& ति" का कर्ता अर्थ को कह रहा है}

\end{document}

enter image description here

share|improve this answer
    
Thanks for your reply, its great. I do not see Unicde code in the callout box. when I type in English then it works great. Also how can I control the space between two boxes because my text is very close and I want to keep the boxes at decent distance. –  Raama Sep 1 '13 at 2:41
    
@Raama please edit your question and add a minimal, complete example code showing the relevant settings. In particular, settings used for the non-English language and a concrete example of the text that you want to apply the call-outs to. –  Gonzalo Medina Sep 1 '13 at 3:05
    
I posted the MWE based on the solution you have given me and the output as well. –  Raama Sep 1 '13 at 3:17
    
@Raama please see my updated answer. You can play with xshift, yshift and the coordinate in callout relative pointer to place the call-outs at specific positions. For the font, simply remove \sffamily from the font attributes. –  Gonzalo Medina Sep 1 '13 at 3:44
    
Thanks a Million, it worked great. –  Raama Sep 1 '13 at 11:44
add comment

You can do this very well with TikZ with the callout shapes from the shapes.callouts library.

The notes are set as a label with the option overlay, so that they do not affect the size of the TikZ picture (we don’t want it to be bigger than the labeled text). For correction of the vertical dimensions the line

\path[draw=none] (tikz@callout.north) -- (tikz@callout.south);

is added, otherwise it will protrude in the next or the previous line.

I wouldn’t use this in running text but put it in a float or at least the center environment.

The base of the callout pointer is as wide as the labeled text (here is and sentence).

The pointer points to the nearest point on the border of the labeled text, this is achieved with the tricky line

tikz@label@post/.append style={/pgf/callout absolute pointer=\tikz@node@at},

that makes sure that \tikz@node@at is evaluated after it is actually computed.

Code

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.callouts}
\makeatletter
\tikzset{
  Text/.style={
    shape=rectangle,
    anchor=base,
    inner xsep=+0pt,
    outer xsep=+0pt,
    outer ysep=+0pt,
    label={[%
      shape=rectangle callout,
      /utils/exec={%
        \pgfpointdiff
          {\pgfpointanchor{\tikzlastnode}{west}}
          {\pgfpointanchor{\tikzlastnode}{east}}},
      callout pointer width/.expanded=\the\pgf@x,
      tikz@label@post/.append style={/pgf/callout absolute pointer=\tikz@node@at},
      alias=tikz@callout]#1}
  },
  label position=below,
  label distance=2ex,
  every label/.style={draw,overlay},
  labels/.style={every label/.append style={#1}}
}
\makeatother
\newcommand*{\myNote}[3][]{%
  \tikz[baseline,#1]{
    \node[Text={#3}] {#2};
    \path[draw=none] (tikz@callout.north) -- (tikz@callout.south);
  }%
}
\begin{document}
  This \myNote{is}{This is a verb.} a \myNote[label position=above]{sentence}{This is another word.}.
\end{document}

Output

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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