
我有一個文檔,我將在頁面的右下角插入圖像。我想這樣做創建一個 minpage 環境。但我找不到在我想要的地方插入此圖像的方法。我怎樣才能做到這一點?
\documentclass[14pt]{extarticle}
\usepackage{fontspec}
\setmainfont{industry-blackitalic}
\usepackage{lipsum}
\usepackage{mwe}
\usepackage{textpos}
\usepackage{graphics}
\pagenumbering{gobble}
\begin{document}
\lipsum [1-1]\\
\newpage %------ II pagina ------------
\lipsum [1-1]\\
\newpage %-------- III pagina ------------
\lipsum [1-1]\\
\newpage %--------IV pagina --------------
\lipsum[1-1]
\end{document}
謝謝
雷納托
答案1
目前還不太清楚,你想要什麼。但是,這裡是如何使用textpos
在一頁的四個角落列印圖像的範例(在範例中是第一個角落):
\documentclass[14pt]{extarticle}
\usepackage{fontspec}
%\setmainfont{industry-blackitalic}% Removed, because not essential for the problem.
%\usepackage{lipsum}% Removed, because also loaded by mwe
\usepackage{mwe}
\usepackage[absolute]{textpos}
\usepackage{graphics}
\pagenumbering{gobble}
\begin{document}
\begin{textblock*}{\paperwidth}(0mm,0mm)% Upper
\raggedright% left edge of page
\includegraphics[page=1,width=4cm]{example-image-a4-numbered}
\end{textblock*}
\begin{textblock*}{\paperwidth}(0mm,0mm)% Upper
\raggedleft% right edge of page
\includegraphics[page=2,width=4cm]{example-image-a4-numbered}
\end{textblock*}
\begin{textblock*}{\paperwidth}(0mm,\paperheight)% Lower
\raggedright% left edge of page
\raisebox{0pt}[0pt][0pt]{\includegraphics[page=3,width=4cm]{example-image-a4-numbered}}
\end{textblock*}
\begin{textblock*}{\paperwidth}(0mm,\paperheight)% Lower
\raggedleft% right edge of page
\raisebox{0pt}[0pt][0pt]{\includegraphics[page=4,width=4cm]{example-image-a4-numbered}}
\end{textblock*}
\lipsum [1-1]%\\% You should never use \\ at the end of a paragraph!
\newpage %------ II pagina ------------
\lipsum [1-1]%\\% You should never use \\ at the end of a paragraph!
\newpage %-------- III pagina ------------
\lipsum [1-1]%\\% You should never use \\ at the end of a paragraph!
\newpage %--------IV pagina --------------
\lipsum[1-1]
\end{document}
如果您希望圖像位於文字區域的角落,只需刪除選項absolute
並替換\paperwidth
為\textwidth
\paperheight
\textheight
。
如果你想要每個頁面都有圖像,使用eso-pic
會更容易:
\documentclass[14pt]{extarticle}
\usepackage{fontspec}
%\setmainfont{industry-blackitalic}% Removed, because not essential for the problem.
%\usepackage{lipsum}% Removed, because also loaded by mwe
\usepackage{mwe}
\usepackage{eso-pic}
\usepackage{adjustbox}
\usepackage{graphics}
\pagenumbering{gobble}
\AddToShipoutPictureBG{% put the images in the background of every page
\AtPageUpperLeft{% upper left corner of the page
\adjincludegraphics[page=1,width=4cm,valign=T]{example-image-a4-numbered}%
}%
\AtPageUpperLeft{% upper
\makebox[\paperwidth][r]{% right corner of the page
\adjincludegraphics[page=2,width=4cm,valign=T]{example-image-a4-numbered}%
}%
}%
\AtPageLowerLeft{% lower left corner of the page
\includegraphics[page=3,width=4cm]{example-image-a4-numbered}%
}%
\AtPageLowerLeft{% lower
\makebox[\paperwidth][r]{% right corner of the page
\includegraphics[page=3,width=4cm]{example-image-a4-numbered}%
}%
}%
}
\begin{document}
\lipsum [1-1]%\\% You should never use \\ at the end of a paragraph!
\newpage %------ II pagina ------------
\lipsum [1-1]%\\% You should never use \\ at the end of a paragraph!
\newpage %-------- III pagina ------------
\lipsum [1-1]%\\% You should never use \\ at the end of a paragraph!
\newpage %--------IV pagina --------------
\lipsum[1-1]
\end{document}
您可以再次調整這些範例,將圖像放置在文字區域而不是紙張的邊緣。為此,再次替換\paperwidth
為\textwidth
並同時替換\AtPageUpperLeft
為\AtTextUpperLeft
和\AtPageLowerLeft
by\AtTextLowerLeft
。
您也可以使用此建議,使用星形變體將圖像僅添加到一頁\AddToShipoutPictureBG*
。
使用最新的 LaTeX,您也可以使用出貨掛鉤:
\documentclass[14pt]{extarticle}
\usepackage{fontspec}
%\setmainfont{industry-blackitalic}% Removed, because not essential for the problem.
%\usepackage{lipsum}% Removed, because also loaded by mwe
\usepackage{mwe}
\usepackage{adjustbox}
\usepackage{graphics}
\pagenumbering{gobble}
\AddToHook{shipout/background}{% Put the images in the background of every page
\put(0,0){% upper left corner
\adjincludegraphics[page=1,width=4cm,valign=T]{example-image-a4-numbered}%
}%
\put(0,0){% upper
\makebox[\paperwidth][r]{% right corner
\adjincludegraphics[page=2,width=4cm,valign=T]{example-image-a4-numbered}%
}%
}%
\put(0,-\pageheight){% lower left corner
\includegraphics[page=3,width=4cm]{example-image-a4-numbered}%
}%
\put(0,-\pageheight){% lower
\makebox[\paperwidth][r]{% right corner
\includegraphics[page=4,width=4cm]{example-image-a4-numbered}%
}%
}%
}
\begin{document}
\lipsum [1-1]%\\% You should never use \\ at the end of a paragraph!
\newpage %------ II pagina ------------
\lipsum [1-1]%\\% You should never use \\ at the end of a paragraph!
\newpage %-------- III pagina ------------
\lipsum [1-1]%\\% You should never use \\ at the end of a paragraph!
\newpage %--------IV pagina --------------
\lipsum[1-1]
\end{document}
有關它們的更多信息,請參閱所用軟體包的手冊。請參閱通用鉤子手冊有關使用掛鉤的資訊。
注意:還有許多其他方法可以將影像或其他資料放置在文件的單一或所有頁面上的固定位置。這裡顯示的可能是最簡單也是最常用的。另一種可能性,很受歡迎蒂克茲用戶,顯示在這個答案到已經作為評論連結的問題。作為相當非常規解決方案的範例,scrlayer-scrpage
此處顯示了包的使用:
\documentclass[14pt]{extarticle}
\usepackage{fontspec}
%\setmainfont{industry-blackitalic}% Removed, because not essential for the problem.
%\usepackage{lipsum}% Removed, because also loaded by mwe
\usepackage{mwe}
\usepackage{adjustbox}
\usepackage{graphics}
\pagenumbering{gobble}
\usepackage{scrlayer-scrpage}
\pagestyle{plain}
\DeclareNewLayer[%
background,%
mode=picture,%
page,
contents={%
\put(0,\paperheight){%
\adjincludegraphics[page=1,width=4cm,valign=T]{example-image-a4-numbered}%
}%
\put(\paperwidth,\paperheight){%
\makebox[0pt][r]{%
\adjincludegraphics[page=2,width=4cm,valign=T]{example-image-a4-numbered}%
}%
}%
\put(0,0){%
\includegraphics[page=3,width=4cm]{example-image-a4-numbered}%
}%
\put(\paperwidth,0){%
\makebox[0pt][r]{%
\includegraphics[page=4,width=4cm]{example-image-a4-numbered}%
}%
}%
}%
]
{cornerimages}
\AddLayersToPageStyle{plain.scrheadings}{cornerimages}
\begin{document}
\lipsum [1-1]%\\% You should never use \\ at the end of a paragraph!
\newpage %------ II pagina ------------
\lipsum [1-1]%\\% You should never use \\ at the end of a paragraph!
\newpage %-------- III pagina ------------
\lipsum [1-1]%\\% You should never use \\ at the end of a paragraph!
\newpage %--------IV pagina --------------
\lipsum[1-1]
\end{document}
此建議的一個很好的功能是,您可以在您想要的每個頁面的每個頁面樣式中新增和刪除新聲明的圖層。您甚至可以聲明帶有或不帶有此圖層的新頁面樣式。因此,\pagenumbering{gobble}
不需要僅包含圖像的頁面:
\documentclass[14pt]{extarticle}
\usepackage{fontspec}
%\setmainfont{industry-blackitalic}% Removed, because not essential for the problem.
%\usepackage{lipsum}% Removed, because also loaded by mwe
\usepackage{mwe}
\usepackage{adjustbox}
\usepackage{graphics}
\usepackage{scrlayer-scrpage}
\DeclareNewLayer[%
background,%
mode=picture,%
page,
contents={%
\put(0,\paperheight){%
\adjincludegraphics[page=1,width=4cm,valign=T]{example-image-a4-numbered}%
}%
\put(\paperwidth,\paperheight){%
\makebox[0pt][r]{%
\adjincludegraphics[page=2,width=4cm,valign=T]{example-image-a4-numbered}%
}%
}%
\put(0,0){%
\includegraphics[page=3,width=4cm]{example-image-a4-numbered}%
}%
\put(\paperwidth,0){%
\makebox[0pt][r]{%
\includegraphics[page=4,width=4cm]{example-image-a4-numbered}%
}%
}%
}%
]
{cornerimages}
\DeclareNewPageStyleByLayers{imagepagestyle}{cornerimages}
\pagestyle{imagepagestyle}
\begin{document}
\pagestyle{empty}
\lipsum[1-3]
\thispagestyle{imagepagestyle}% Use the images only on this page
\lipsum[4-10]
\pagestyle{imagepagestyle}% And from this page.
\lipsum
\end{document}
答案2
儘管您的問題相當令人困惑(您應該至少顯示一個您期望的輸出範例以及一個最小的程式碼範例來重現您的問題),但我將嘗試“猜測”您想要做什麼:
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\begin{document}
% Your document content here
\vfill % push the minipage to the bottom of the page
\noindent % prevent indentation
\begin{minipage}[b]{\linewidth}
\raggedleft % right-align the content of the minipage
\includegraphics[width=0.3\linewidth]{example-image} % replace 'example-image' with your image file name
\end{minipage}
\end{document}