使用我正在编写的一些 org-mode 代码,我在导出为 HTML5 格式时得到了预期的图像位置,但在导出为 PDF 时得到了错误的位置。
这是我使用的语法:
#+TITLE: Article title
#+DATE: 2023-02-02
#+AUTHOR: me <[email protected]>
#+EMAIL: [email protected]
#+LANGUAGE: en
#+OPTIONS: toc:2
#+LaTeX_HEADER: \author{me}
#+HTML_DOCTYPE: html5
** Chapter1 title
Bla bla 1...
#+CAPTION: Image caption
#+NAME: fig:plot1
[[./MyArticle_files/plot1.png]]
bla bla 2:
#+NAME: fig:plot2
[[./MyArticle_files/plot2.png]]
bla bla 3:
#+NAME: fig:plot3
[[./MyArticle_files/plot3.png]]
bla bla 4.
** Chapter2 title
在 HTML5 中,我按照与 org-mode 文件中相同的顺序获取文本和图像。在 PDF 中,我得到:
** Chapter1 title
Bla bla 1...
bla bla 2:
bla bla 3:
bla bla 4.
** Chapter2 title
plot1.png
plot2.png
plot3.png
为了进行转换,我正在使用Pandoc:
pandoc -s ./text.org -t html5 -o ./text.html
pandoc -s ./text.org -o ./text.tex
pandoc -s ./text.org -o ./text.pdf
这是tex转换输出:
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
]{article}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
\KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\ifLuaTeX
\usepackage[bidi=basic]{babel}
\else
\usepackage[bidi=default]{babel}
\fi
\babelprovide[main,import]{english}
% get rid of language-specific shorthands (see #6817):
\let\LanguageShortHands\languageshorthands
\def\languageshorthands#1{}
\author{me}
\ifLuaTeX
\usepackage{selnolig} % disable illegal ligatures
\fi
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\urlstyle{same} % disable monospaced font for URLs
\hypersetup{
pdftitle={Article title},
pdfauthor={me \textless [email protected]\textgreater{}},
pdflang={en},
hidelinks,
pdfcreator={LaTeX via pandoc}}
\title{Article title}
\author{me \textless [email protected]\textgreater{}}
\date{2023-02-02}
\begin{document}
\maketitle
\hypertarget{chapter1-title}{%
\subsection{Chapter1 title}\label{chapter1-title}}
Bla bla 1\ldots{}
\begin{figure}
\centering
\includegraphics{./MyArticle_files/plot1.png}
\caption{Image caption}
\end{figure}
bla bla 2:
\begin{figure}
\centering
\includegraphics{./MyArticle_files/plot2.png}
\caption{}
\end{figure}
bla bla 3:
\begin{figure}
\centering
\includegraphics{./MyArticle_files/plot3.png}
\caption{}
\end{figure}
bla bla 4.
\hypertarget{chapter2-title}{%
\subsection{Chapter2 title}\label{chapter2-title}}
\end{document}