2

I used the technique described by the commentator "Martin H" here to include an Inkscape graphic into my LaTex document.

Now I want to force all the text of the image to look exactly like in math mode, i.e. \mathnormal, because that the image include parameters names etc.

I'm aware of the option to delimit the text with \(\), so that it would look like I need. But it seems like a last-resort option.

So I read here that the default math font is Latin Modern Math.
I had tried to force that font on the text:

{\setmainfont{Latin Modern Math}
\input{drawing.pdf_tex}
}

But it didn't look like the default math font. Why's that?


Edit #1:

A minimal working example:

The Tex file:

\documentclass{article}

%\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{color}
\usepackage{graphicx}
\usepackage{fontspec}

\begin{document}
\pagestyle{empty}
Hello World!

This \(x^2\) equation
{\setmainfont{Latin Modern Math}
\input{drawing.pdf_tex}
}
\end{document}

The file drawing.pdf_tex:

%% Creator: Inkscape inkscape 0.48.4, www.inkscape.org
%% PDF/EPS/PS + LaTeX output extension by Johan Engelen, 2010
%% Accompanies image file 'drawing.pdf' (pdf, eps, ps)
%%
%% To include the image in your LaTeX document, write
%%   \input{<filename>.pdf_tex}
%%  instead of
%%   \includegraphics{<filename>.pdf}
%% To scale the image, write
%%   \def\svgwidth{<desired width>}
%%   \input{<filename>.pdf_tex}
%%  instead of
%%   \includegraphics[width=<desired width>]{<filename>.pdf}
%%
%% Images with a different path to the parent latex file can
%% be accessed with the `import' package (which may need to be
%% installed) using
%%   \usepackage{import}
%% in the preamble, and then including the image with
%%   \import{<path to file>}{<filename>.pdf_tex}
%% Alternatively, one can specify
%%   \graphicspath{{<path to file>/}}
%% 
%% For more information, please see info/svg-inkscape on CTAN:
%%   http://tug.ctan.org/tex-archive/info/svg-inkscape
%%
\begingroup%
  \makeatletter%
  \providecommand\color[2][]{%
    \errmessage{(Inkscape) Color is used for the text in Inkscape, but the package 'color.sty' is not loaded}%
    \renewcommand\color[2][]{}%
  }%
  \providecommand\transparent[1]{%
    \errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}%
    \renewcommand\transparent[1]{}%
  }%
  \providecommand\rotatebox[2]{#2}%
  \ifx\svgwidth\undefined%
    \setlength{\unitlength}{80.4138855bp}%
    \ifx\svgscale\undefined%
      \relax%
    \else%
      \setlength{\unitlength}{\unitlength * \real{\svgscale}}%
    \fi%
  \else%
    \setlength{\unitlength}{\svgwidth}%
  \fi%
  \global\let\svgwidth\undefined%
  \global\let\svgscale\undefined%
  \makeatother%
  \begin{picture}(1,0.90155469)%
    \put(0,0){\includegraphics[width=\unitlength]{drawing.pdf}}%
    \put(0.32238442,0.5481293){\makebox(0,0)[lb]{\smash{v0}}}%
  \end{picture}%
\endgroup%

Notice that the line:

\put(0.32238442,0.5481293){\makebox(0,0)[lb]{\smash{v0}}}%

has the parameter name v0.

The drawing file is at: http://www.filedropper.com/drawing_3
(SE network doesn't allow uploading a file which isn't an image, so I uploaded it to a different website.)


Edit #2:

Following "Mico" guidance, I modified to code of the main LaTex file to be:

\documentclass{article}

\usepackage{mathtools}
\usepackage{color}
\usepackage{graphicx}
\usepackage{fontspec}

\begin{document}

Example of "v0" in math mode: \(v_0\).\\
But in the drawing it looks otherwise:\\

\input drawing

\end{document}

Also, changed the name of the file drawing.pdf_tex to be drawing.tex.
Then I compiled the main LaTex file with lualatex (normally I use xelatex, does it make a difference?).

But the text of math mode looks different than the text of the image, see:

enter image description here

BTW, having:

{\setmainfont{Latin Modern Math}
\input drawing
}

instead of simply:

{
\input drawing
}

doesn't make a difference - it yields the same results as in the image above.

2
  • Maybe {\setmainfont{Latin Modern Math}\itseries{\input{...}}}? We will need to see an MWE in order to help.
    – LaRiFaRi
    Mar 5, 2015 at 13:39
  • @LaRiFaRi It doesn't work, says ! Undefined control sequence. l.14 {\setmainfont{Latin Modern Math}\itseries. Plz see my edit.
    – Dor
    Mar 5, 2015 at 13:56

1 Answer 1

1

If I change the name of the subsidiary file drawing.pdf_tex to drawing.tex and load it in the main file via \input drawing (note that .tex is optional), and also make sure to compile the main file with LuaLaTeX, I get the following result:

enter image description here

Note that the example code uses default text and math fonts that are rather different from Latin Modern. Nevertheless, the v0 string is clearly set in Latin Modern.

\documentclass{article}
\usepackage{mathtools}
\usepackage{color}
\usepackage{graphicx}
\usepackage{fontspec}
\usepackage{unicode-math}

% just for this example
   \setmainfont{EB Garamond} 
   \setmathfont[Scale=MatchLowercase]{Cambria Math}

\begin{document}
\pagestyle{empty}
Hello World!

This \(x^2\) equation
\begingroup
   \setmainfont{Latin Modern Roman}
   \setmathfont{Latin Modern Math}
   \input drawing
\endgroup
\end{document}
6
  • Thank you for your answer, but please see my 2nd edit, I hope it is clearer.
    – Dor
    Mar 5, 2015 at 18:21
  • @dor - Inside drawing.tex, the instruction that prints "v0", viz., \makebox(0,0)[lb]{\smash{v0}}, is executed in text mode, not math mode. That's why it does not look the same as when you write \(v0\). The reason the text generated by the main file in Edit#2 looks the same inside and outside the group is that Latin Modern is the default font family, i.e., it's loaded if no other fonts are loaded explicitly. I deliberately chose a different text font (EB Garamond) and math font (Cambria Math) in the answer I gave in order to illustrate the difference caused by switching fonts.
    – Mico
    Mar 5, 2015 at 19:21
  • So the font isn't the issue, but it is the mode (text or math) that sets the neat look? I tried to delimit the text in drawing.tex using \(\) and it worked, but I thought that maybe there is another, more general solution to make all that text look like it is in math mode. Because that maybe I'll need to modify the image many times, so delimiting the text with \(\) each and every time will be tiresome.
    – Dor
    Mar 5, 2015 at 19:38
  • @Dor - TeX's math mode should only be used for math-mode material. Speaking for myself, I don't think that writing either \(v0\) or $v0$ is particularly burdensome or time-consuming.
    – Mico
    Mar 5, 2015 at 19:44
  • Indeed. But how exactly math mode design the text? I mean, what does it do and would I be able to mimic the style?
    – Dor
    Mar 5, 2015 at 21:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .