# Is it possible to get the location of individual components of a LaTeX image?

I'm writing an android app and I want to render math expressions in LaTeX then react to touches to individual parts of the rendered expression.

I'm planning on using a library like jlatexmath.

I know almost nothing about LaTeX, but as far as I can tell, it renders to a single image. Is there any way for me to figure out which parts of the image belong to which symbols? (for example, knowing that the left 17% is an integral sign)

• LaTeX renders to a PDF or a DVI (which is an old-fashioned PDF). I think you'll get better results with MathJax, which produces HTML and CSS from LaTeX syntax but doesn't use LaTeX internally. – ChrisS Jun 15 '14 at 2:48
• @ChrisS I've been looking at MathJax and it looks like it could work really well - Android webviews support javascript and interface it with java, which looks like it could work really well. Do you know anything about javascript? Do you know if it's feasible for me to somehow identify the javascript elements and use javascript touch events on them? – xyzzy Jun 15 '14 at 7:50

If you use the tabstackengine package to apply tabbing to your expression, then the various cells of the most recently set content are stored. Thus, they can be recalled and measured to perhaps achieve your goal. For vertically stacked content, the package can also remember the strut height of each row (not shown in this MWE).

The empty braces {} following the \TABcell{i}{column} invocations conforms to the package's default settings, to allow operators (like an integral sign) and relations to be set as if there is something that follows.

\documentclass{article}
\usepackage{tabstackengine}
\stackMath
\begin{document}
\tabbedCenterstack{\displaystyle\int_0^1&\displaystyle x^2\,dx = 1/3}

\setbox0=\hbox{$\TABcell{i}{1}{}$}\setbox1=\hbox{$\TABcell{i}{2}{}$}

\rule{.2pt}{2ex}\kern-.2pt\hspace{\wd0}%
\rule{.2pt}{2ex}\kern-.2pt \hspace{\wd1}\rule{.2pt}{2ex}

\the\wd0\ is the integral sign width

\the\wd1\ is the rest of the expression width
\end{document}