# Math equation - to PDF - fully searchable?

I'm a complete newbie to Latex, and I am trying to use it for creating small pdf images with equations. My requirements are:

• Aligned equations
• Clear font (bold and italic)
• Minimal sized image in PDF format
• Searchable in PDF format

This version finally creates a small PDF without margins, but the problem I run into is with searching. For some fonts, I can't search for comma (in case I want to find "x,y". In some versions, the first letter of a word isn't searchable with the rest of the word, so "Sample" is not searchable. In some fonts, I can't search for a word ending in ff, the second f is not searchable. Is there an easy solution to this?

To create the file:

pdflatex --file-line-error --interaction=nonstopmode testcode.tex


Thank you so much!

\documentclass{amsart}
\usepackage{txfonts}
\usepackage[T1]{fontenc}
\usepackage[margin=0pt]{geometry}
\usepackage[active,tightpage]{preview}
\usepackage{varwidth}
\begin{document}
\begin{preview}
\begin{varwidth}{\linewidth}
\nonumber \begin{aligned} &Example\_VAL_{x,y} &&= \sum\nolimits_{i=0}^{MARK\_n}VAL_{x,y,i} * VAL_i \\ &Example\_VAL2_{x,y} &&= \sum\nolimits_{i=0}^{MARK\_n}VAL2_{x,y,i} * VAL_i \end{aligned}
\end{varwidth}
\end{preview}
\end{document}


Latest version after help from Ulrike, and trying to simplify code writing for myself:

\documentclass[varwidth=\maxdimen,border=2pt]{standalone}
\usepackage{luatex85}
\usepackage{amsmath}
\usepackage{unicode-math}
\usepackage[italic]{mathastext}
\setmainfont{TeX Gyre Termes} %Times clone
\setmathfont{TeX Gyre Termes Math} %accompagning math.

\begin{document}
\nonumber\begin{aligned} &Example\_VAL_{x,y} &&= \sum\nolimits_{i=0}^{MARK\_n}VAL_{x,y,i} * VAL_{i} \\ &Example\_VAL2_{x,y} &&= \sum\nolimits_{i=0}^{MARK\_n}VAL2_{x,y,i} * VAL_{i} \end{aligned}
\end{document}


Curious how to get a slanted more normal font in the equation - without embedding myvar throughout.

If you want searchable math you should better use one of the unicode engines (lualatex or xelatex). With pdflatex it would involve a lot juggling with accsupp.

And if you have long "Textvariables" then better set them with the text font. Beside this I would suggest to use the standalone class.

\documentclass[varwidth,border=2pt]{standalone}
\usepackage{luatex85}
\usepackage{amsmath}

\usepackage{unicode-math}
\setmainfont{TeX Gyre Termes} %Times clone
\setmathfont{TeX Gyre Termes Math} %accompagning math.
\newcommand\myvar[1]{\text{\normalfont\itshape #1}}
\begin{document}
\nonumber \begin{aligned} &\myvar{Example\_VAL}_{x,y} &&= \sum\nolimits_{i=0}^{\myvar{MARK\_n}}\myvar{VAL}_{x,y,i} * \myvar{VAL}_i \\ &\myvar{Example\_VAL2}_{x,y} &&= \sum\nolimits_{i=0}^{\myvar{MARK\_n}}\myvar{VAL2}_{x,y,i} * \myvar{VAL}_i \end{aligned}
\end{document}


• Thanks for the quick answer. After creating the PDF, the character 'x' is missed in the x,y. So when I search for x, I get the 'x' in example but not the x in the subscript. I've tried using Adobe Acrobat and MacOS Preview. Any way to get all characters and words to be searchable? – nachum Apr 23 '17 at 15:11
• The x in text (Unicode U+0078) is a quite different char then a mathematical 𝑥 (U+1D465). – Ulrike Fischer Apr 23 '17 at 16:18
• How do I use the 'x' from text and not math? – nachum Apr 23 '17 at 19:41