我必须填写一份表格,我想用 Latex 填写。我怎样才能插入包含表格的 pdf/word 文件,并用 Latex 在上面书写?
谢谢你!
答案1
我和 Henri 的理解不同 - 我假设您想在已经存在的 PDF 文件上书写。(如果您有 Word 文件,则需要先转换为 PDF。)
您可以使用textpos
包来执行您的命令,但我更喜欢使用tikz
,因为我无论如何都更经常使用它并且更习惯它。以下是一个例子。
\documentclass[11pt]{article}
\usepackage{lmodern,tikz,calc}
\usepackage[margin=0pt]{geometry}
\pagestyle{empty}
% text bold and red just for this example. Text nodes will be aligned
% by their bottom left corners.
\tikzstyle{every node}=[anchor=base west,text=red,font=\bfseries]
% save the existing form in a box; we use the size of that
% box to scale the coordinates. That way, the text elements will
% stay in their right places in case the graphic is resized later.
\newsavebox{\mybox}
\savebox{\mybox}{\includegraphics[width=0.9\textwidth]{picture}}
\newlength{\boxwidth}
\newlength{\boxheight}
\setlength{\boxwidth}{\wd\mybox}
\setlength{\boxheight}{\ht\mybox+\dp\mybox}
% define coordinate grid relative to box width
\newlength{\gridstep}
\setlength{\gridstep}{0.2\boxwidth}
\newcommand{\tikzgrid}[2][5in]{
\draw[step=.1in,gray,very thin] (0,0) grid (#1,#2);
\draw[step=.5in,black,very thin] (0,0) grid (#1,#2);
}
\begin{document}
\null\vfill
\centering
\begin{tikzpicture}[x=\gridstep,y=\gridstep]
% insert background image
\node at (0,0){\usebox{\mybox}};
% draw help lines. comment out once you are done placing the text elements.
\draw[step=0.25\gridstep,black!20,very thin] (0,0) grid (\boxwidth,\boxheight);
\draw[step=\gridstep,black,very thin] (0,0) grid (\boxwidth,\boxheight);
% the text elements. the coordinates in brackets are in units of
% the major (black) help lines.
\path
(0.75,5.05) node {Pomegranate}
(1.75,4.75) node {roasted marshmallow}
(1.5,4.4) node {Pokemons}
% a text node with line breaks and non-standard positioning
(1.5,0.75) node[anchor=north west,text width=1in]
{Mom,\\Dad,\\lil brotha.}
;
\end{tikzpicture}
\vfill
\end{document}