我想要用 Inkscape 编写以下文本并将其导出到 pdf_tex:
erfasste
Regelgröße $x_{\mathrm{r}}$
但是在Texmaker中运行pdf_tex之后的结果如下所示:
为什么两行之间没有空白处?
这是一个单独的文本块。我想用以下代码来实现它:
\begin{document}
\begin{figure}[h]
\centering
\begin{normalsize}
\import{drawing.pdf_tex}
\end{normalsize}
\end{figure}
\end{document}
我的目录顺序:
- 主文本
- 图片
- 绘图.pdf_tex
- 图纸.pdf
- 特克斯
- 章节
并且代码写在了chap.tex
所包含的文件中main.tex
。
这是我的pdf_tex
文件:
%% Creator: Inkscape 1.0.1 (3bc2e813f5, 2020-09-07), www.inkscape.org
%% PDF/EPS/PS + LaTeX output extension by Johan Engelen, 2010
%% Accompanies image file 'Struktur_Regelkreis_3.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}%
\newcommand*\fsize{\dimexpr\f@size pt\relax}%
\newcommand*\lineheight[1]{\fontsize{\fsize}{#1\fsize}\selectfont}%
\ifx\svgwidth\undefined%
\setlength{\unitlength}{145.83385778bp}%
\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.17768981)%
\lineheight{1}%
\setlength\tabcolsep{0pt}%
\put(-0.00140624,0.12063649){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{0}\smash{\begin{tabular}[t]{l}erfasste\\Regelgröße\textit{ $x_{\mathrm{r}}$}\end{tabular}}}}%
\end{picture}%
\endgroup%
答案1
使用Inkscape 1.1
你的代码我得到以下
drawing.pdf_tex
%% 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}%
\newcommand*\fsize{\dimexpr\f@size pt\relax}%
\newcommand*\lineheight[1]{\fontsize{\fsize}{#1\fsize}\selectfont}%
\ifx\svgwidth\undefined%
\setlength{\unitlength}{414.74844856bp}%
\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.1631104)%
\lineheight{1}%
\setlength\tabcolsep{0pt}%
\put(-0.0039783,0.10777583){\color[rgb]{0,0,0}\makebox(0,0)[lt]{\lineheight{1.25}\smash{\begin{tabular}[t]{l}erfasste\\Regelgröße $x_{\mathrm{r}}$\end{tabular}}}}%
\end{picture}%
\endgroup%
使用复制/过去 A| 工具
和pdfTeX, Version 3.141592653-2.6-1.40.24 (MiKTeX 22.3)
% !TeX TS-program = pdflatex
\documentclass{article}
\usepackage{color}
\begin{document}
\input{drawing.pdf_tex}
\end{document}
结果是正确的
输出排版为
\begin{tabular}[t]{l}
erfasste\\Regelgröße $x_{\mathrm{r}}$
\end{tabular}
略微\baselineskip
从 12pt 增加到 12.5pt。
更新
您需要添加包color
和 import
。
在我的系统中,该文件drawing.pdf_tex
位于同一目录中,main.tex
因此我使用
\import{./}{drawing.pdf_tex}
一般来说 \import{<path to file>}{<filename>.pdf_tex}
二使用您的目录结构:
这是main.tex
% !TeX TS-program = pdflatex
\documentclass{book}
\usepackage{xcolor}% needed <<<
\usepackage{import} % needed <<<
\begin{document}
\input{./TEX/chap}
\end{document}
这是chap.tex
%% file chap.tex
\chapter{ONE}
Some text
\begin{figure}[h!]
\centering
\begin{normalsize}
\import{./IMG/}{drawing.pdf_tex}
\end{normalsize}
\end{figure}
生产