图像路径也绘制在 pdf 中

图像路径也绘制在 pdf 中

我遇到了以下问题:如果我将 tex 文件导出为 pdf,我不仅会得到图形,还会得到图形上方的路径。我该如何避免这种情况?

  \documentclass{article}%
    \usepackage[T1]{fontenc}%
    \usepackage[utf8]{inputenc}%
    \usepackage{lmodern}%
    \usepackage{textcomp}%
    \usepackage{lastpage}%
    \usepackage[head=1pt,margin=0.3in,bottom=0.3in,includeheadfoot=False]{geometry}%
    \usepackage{graphicx}%
    %
    \usepackage{helvet}%
    \usepackage[utf8]{inputenc}%
    \usepackage{needspace}%
    \newcommand*\measurePage{\par\setlength{\measurepage}{\dimexpr\pagegoal-\pagetotal-\baselineskip}}%
    \usepackage{textcomp}%
    %
    \begin{document}%
    \normalsize%


    \begin{figure}[h!]%
    \centering%
    \includegraphics[width=\linewidth]{C:/Users/EPFL/Google Drive/Mooc/Cellular Mechanisms of Brain Functions/Text And Slides/1/Slides/1.jpg}%
    \end{figure}

    \end{document}

在此处输入图片描述

答案1

如果您指定的文件路径包含空格,就会发生这种情况。您应该将图像路径括在双引号 ( ") 中,并省略文件扩展名:

\documentclass{article}%
\usepackage[T1]{fontenc}%
\usepackage[utf8]{inputenc}%
\usepackage{lmodern}%
\usepackage{textcomp}%
\usepackage{lastpage}%
\usepackage[head=1pt,margin=0.3in,bottom=0.3in,includeheadfoot=False]{geometry}%
\usepackage{graphicx}%
%
\usepackage{helvet}%
\usepackage[utf8]{inputenc}%
\usepackage{needspace}%
\newcommand*\measurePage{\par\setlength{\measurepage}{\dimexpr\pagegoal-\pagetotal-\baselineskip}}%
\usepackage{textcomp}%
%
\begin{document}%
\normalsize%


\begin{figure}[h!]%
\centering%
\includegraphics[width=\linewidth]{"C:/Users/EPFL/Google Drive/Mooc/Cellular Mechanisms of Brain Functions/Text And Slides/1/Slides/1"}%
\end{figure}

\end{document}

如果文件位于主 TeX 文件的子文件夹中,最好使用相对(无空格)路径。您还可以考虑将该文件夹添加到您的\graphicspath(我不知道这对于包含空格的路径是否有效)。

相关内容