6

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}
\begin{equation}
\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{equation}
\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.

nachum
  • 163
  • See the answer to this question, https://tex.stackexchange.com/questions/233390/in-which-way-have-fake-spaces-made-it-to-actual-use, for how to make your math searchable (i.e., copy/paste-able) in a pdflatex setting. – Steven B. Segletes Apr 23 '17 at 17:38

1 Answers1

4

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}

enter image description here

Ulrike Fischer
  • 327,261
  • 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