Latex - 是否可以在图像之上添加文本?

发布于 2024-08-28 15:31:26 字数 77 浏览 4 评论 0原文

我想使用 Latex 创建类似传单/杂志的东西。是否可以将文本放置在图像之上并自由设置文本样式?

有类似这样的例子的链接吗?

I want to create something like a leaflet/magazine using Latex. Is it possible to place text on top of an image and style the text freely?

Any links to examples of something like this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

绿光 2024-09-04 15:31:26

我通常会做类似的事情

\usepackage{tikz}
...
\begin{tikzpicture}
    \draw (0, 0) node[inner sep=0] {\includegraphics[width=4cm]{imagefile.png}};
    \draw (1, 1) node {Hello world};
\end{tikzpicture}

I usually do something like

\usepackage{tikz}
...
\begin{tikzpicture}
    \draw (0, 0) node[inner sep=0] {\includegraphics[width=4cm]{imagefile.png}};
    \draw (1, 1) node {Hello world};
\end{tikzpicture}
凡尘雨 2024-09-04 15:31:26

您还可以在图像之后定义文本,然后使用负垂直空间对其进行偏移。因为它跟随在 LaTeX 源中的图像之后,所以它将绘制在图像的顶部而不是图像的下面。

\includegraphics[...]{...}
\vspace*{-20ex}  % Tune this to the image height.
\begin{center}
Text
\end{center}
\vspace*{20ex}  % The spacing above but without the minus.

You can also define the text after the image and then offset it using negative vertical space. Because it follows after the image in the LaTeX source, it will be drawn on top of the image instead of underneath it.

\includegraphics[...]{...}
\vspace*{-20ex}  % Tune this to the image height.
\begin{center}
Text
\end{center}
\vspace*{20ex}  % The spacing above but without the minus.
澉约 2024-09-04 15:31:26

一个非常好的图像操作工具集是 pgf/TikZ pdf文档

有关示例,请参阅 \pgfimage。它允许自由混合文本和图像。有很多方法可以做到这一点。其中之一是使用图层pgf 手册)。 pgf 手册包含许多简单的示例,并且非常精确。

另一个解决方案是使用 lpic 包:主页< /a> 包含一些示例。

您可以在 此处找到 pfg 和 TikZ 的其他示例此处提供了许多令人印象深刻的示例。

A very good toolset for manipulating images is pgf/TikZ pdf doc.

See \pgfimage for examples. It allows to mix text and image freely. There are many ways to do it. One of them is to use layers (p. 220 of pgfmanual). The pgf manual contains many simple examples, and is very precise.

Another solution is to use the lpic package: the homepage contains some examples.

You can find other examples for pfg and TikZ here and here for many impressive examples.

霓裳挽歌倾城醉 2024-09-04 15:31:26

正如已经建议的,您可以使用 TikZ 注释图的不同部分。然而,有时使用数字来引用不同的部分并在图标题中解释它们可能会更好。

为了轻松获得精确的相对位置(这通常很乏味)并自动生成 LaTeX 代码,您可以使用新的基于 Web 的 LaTeX Overlay Generator,我为这种情况构建的。这只是一个小型互动工具,可以帮助您找到正确的位置。

As already suggested, you can annotate the different parts of the figure using TikZ. However, sometimes it might even better to use numbers to reference the different parts and explain them in the figure caption.

To easily get the precise relative positions (which is often tedious) and to generate LaTeX code automatically, you could use the new web-based LaTeX Overlay Generator, which I built for such cases. This is just a small interactive tool, which helps you to find the right locations.

幸福不弃 2024-09-04 15:31:26

另一个解决方案是 textpos 包,它允许您指定页面上绝对位置的框。这些框可以重叠,因此您可以将图形放在一个框中,将文本放在其上方的另一个框中。

Another solution is the textpos package which allows you to specify boxes at absolute positions on the page. The boxes can overlap, so you can put the figure in one box, and text in another box on top of it.

﹎☆浅夏丿初晴 2024-09-04 15:31:26

我意识到这个问题已经很老了,答案已被接受,但为了完整性,我想提出一种用 LaTeX 制作传单的替代方法。

具体来说,传单文档样式非常适合我目的。

可以在此处找到有关背景图像的优秀博客文章。为了使所提出的方法发挥作用,需要使用几个包,但博客文章中没有提到:

\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{transparent}

I realise that the question is old and answer is accepted, but for completeness would like to propose an alternative approach for making leaflets in LaTeX.

Specifically, the leaflet document style served me really well for this purpose.

A good blog post wrt background image can be found here. There are a couple of packages that are required to use in order to make the proposed approach work, but were not mentioned in the blog post:

\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{transparent}
呢古 2024-09-04 15:31:26

另一种方法是使用 Photoshop 或 gimp 或类似的工具来编辑图像,当然不使用 LaTeX。我想你在排版数学方面的选择可能会相当有限。

否则我会赞成使用 tikz。

您确定要在 LaTeX 中执行此操作吗?桌面出版软件可能更适合您的需求...像 scribus 这样的东西可能比 tikz 更容易学习曲线,取决于你想做什么。

Another way to do this, admittedly not using LaTeX, would simply be to edit the image with photoshop or gimp or something like that. I guess your option in terms of typesetting mathematics might be fairly limited doing it this way.

Otherwise I'd endorse using tikz.

Are you sure you want to do it in LaTeX? Desktop publishing software might be more suited to your needs... Something like scribus might be easier than tikz in terms of learning curve, depending on what you want to do.

萌辣 2024-09-04 15:31:26

我想补充@midtiby的答案...

您还可以使用相对位置指定文本位置,如下所示:

\usepackage{tikz}
...
\begin{tikzpicture}
    \node[inner sep=0] (image) at (0,0) {\includegraphics[width=4cm]{imagefile.png}};
    \node[above=0 of image] {Hello world};
 \end{tikzpicture}

I'd like to add on to @midtiby's answer...

You can also specify the text position using a relative position, like so:

\usepackage{tikz}
...
\begin{tikzpicture}
    \node[inner sep=0] (image) at (0,0) {\includegraphics[width=4cm]{imagefile.png}};
    \node[above=0 of image] {Hello world};
 \end{tikzpicture}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文