LaTeX 可以依 mm 座標放置文字嗎?

LaTeX 可以依 mm 座標放置文字嗎?

我的系統產生 LaTex 字母和模板;然而,我的客戶必須填寫他們無法控制的預建表格。我想透過測量以毫米為單位的座標來填寫這些表格,然後使用這些以毫米為單位的座標作為起點來放置文字。然後我可以直接在現有的紙本表格上列印。

理想情況下,我希望 LaTeX 的功能如下:

\command{x coordinate}{y coordinate}{text1}\\
\command{x coordinate}{y coordinate}{text2}\\
\command{x coordinate}{y coordinate}{text3}\\
\command{x coordinate}{y coordinate}{text4}\\
\command{x coordinate}{y coordinate}{text5}\\
\command{x coordinate}{y coordinate}{text6}\\

如果客戶表格發生變化,我只需更改座標即可。這種方法可行嗎?

答案1

一種選擇是使用 TikZ。所有距離都是從紙張的左上角開始測量的(可以輕鬆修改以選擇另一個原點):

\documentclass{article}
\usepackage{tikz}

\newcommand\PlaceText[3]{%
\begin{tikzpicture}[remember picture,overlay]
\node[outer sep=0pt,inner sep=0pt,anchor=south west] 
  at ([xshift=#1,yshift=-#2]current page.north west) {#3};
\end{tikzpicture}%
}

\begin{document}

\PlaceText{20mm}{30mm}{First text}
\PlaceText{50mm}{30mm}{Second text}
\PlaceText{60mm}{70mm}{Third text}

\end{document}

在此輸入影像描述

答案2

textpos

\documentclass[a4paper]{article}
\usepackage[overlay,absolute]{textpos}
\newcommand\PlaceText[3]{%
\begin{textblock*}{10in}(#1,#2)  %% change width of box from 10in as you wish
#3
\end{textblock*}
}%
\textblockorigin{-5mm}{0mm}   %% Default origin top left corner and it can be changed in this line
\begin{document}
\PlaceText{0mm}{0mm}{Origin}
\PlaceText{20mm}{30mm}{First text}
\PlaceText{50mm}{30mm}{Second text}
\PlaceText{60mm}{70mm}{Third text}

\end{document}

在此輸入影像描述

相關內容