最小示例:
\documentclass{memoir}
\usepackage[utf8]{inputenc}
\thispagestyle{empty}
\begin{document}
\begingroup
\color{blue}
\rule{\paperwidth}{7.5cm}
\endgroup
\end{document}
我只想制作一个蓝色的、具有纸张宽度的、位于底部且高 7.5 厘米的盒子。如何做到这一点?
提前谢谢您:)
PS!如果我能写一段文字,从右边缘 7 厘米处开始,到右边缘最多 2 厘米处,从蓝色开头下方 2 厘米处开始,到底部前 1 厘米处结束(白色文本),那就太好了:D
还有一张距离纸张每条边 2 厘米的图片(也在蓝色框中),长 9 厘米。
答案1
尝试这个:
在序言中加载这些包
\usepackage{fancybox}
\usepackage{color}
\usepackage{calc}
然后:
\colorbox{blue}{
\parbox[b][7.5cm][t]{\textwidth}{\hspace*{7cm}
\parbox[t][5.5cm][t]{\textwidth-9cm}{\textcolor{red}{\\[2cm]
Some text that non makes sense\hfill at all,\vfill just for practicing\ldots\hfill the example }}
%\makebox[0.5\textwidth-9cm][l]{ \textcolor{white}{Some text that non makes sense at all, just for practicing the example }}
}
}
这将产生以下输出:
答案2
根据我的回答有哪些方法可以将内容绝对定位在页面上?
已修改以使用嵌套的解决方案\stackinsets
。注意:文本将垂直居中于白色框中。
\documentclass{memoir}
\usepackage[utf8]{inputenc}
\thispagestyle{empty}
\usepackage{graphicx}
\usepackage{everypage}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{stackengine}
% THESE ARE LaTeX DEFAULTS; CAN CHANGE IF NEEDED.
\def\PageTopMargin{1in}
\def\PageLeftMargin{1in}
\newcommand\atxy[3]{%
\AddThispageHook{\smash{\hspace*{\dimexpr-\PageLeftMargin-\hoffset+#1\relax}%
\raisebox{\dimexpr\PageTopMargin+\voffset-#2\relax}{#3}}}}
\begin{document}
\def\blocktext{%
This is a test of text in my parbox. Will it wrap properly? I think it will.}
\atxy{0in}{11in}{%
\stackinset{r}{2.5cm}{c}{0cm}{\parbox[c]{4cm}{\blocktext}}{%
\stackinset{l}{2cm}{b}{2cm}{\includegraphics[width=9cm,height=3.5cm]{example-image-a}}{%
\stackinset{r}{2cm}{b}{2cm}{\textcolor{white}{\rule{5cm}{3.5cm}}}{%
\textcolor{blue}{\rule{\paperwidth}{7.5cm}}%
}}}%
}
\lipsum[1-4]\clearpage
\end{document}
原始解决方案(无堆栈):
我用一个大的 绘制蓝色\rule
,然后覆盖一个白色块作为未来的文本,以及一个图像,最后\parbox
为文本。
\documentclass{memoir}
\usepackage[utf8]{inputenc}
\thispagestyle{empty}
\usepackage{graphicx}
\usepackage{everypage}
\usepackage{xcolor}
\usepackage{lipsum}
% THESE ARE LaTeX DEFAULTS; CAN CHANGE IF NEEDED.
\def\PageTopMargin{1in}
\def\PageLeftMargin{1in}
\newcommand\atxy[3]{%
\AddThispageHook{\smash{\hspace*{\dimexpr-\PageLeftMargin-\hoffset+#1\relax}%
\raisebox{\dimexpr\PageTopMargin+\voffset-#2\relax}{#3}}}}
\begin{document}
\atxy{0in}{11in}{\textcolor{blue}{\rule{\paperwidth}{7.5cm}}}
\atxy{\dimexpr\paperwidth-7cm}{\dimexpr11in-2cm}{\textcolor{white}{%
\rule{5cm}{3.5cm}}}
\atxy{2cm}{\dimexpr11in-2cm}{%
\includegraphics[width=9cm,height=3.5cm]{example-image-a}}
\atxy{\dimexpr\paperwidth-6.5cm}{\dimexpr11in-4.8cm}{\parbox[t]{4cm}{%
This is a test of text in my parbox. Will it wrap properly? I think it will.}}
\lipsum[1-4]\clearpage
\end{document}
答案3
这里有一个选项tikz
。
\documentclass{memoir}
\usepackage{tikz}
\usetikzlibrary{calc}
\thispagestyle{empty}
\begin{document}
\begin{tikzpicture}[remember picture, overlay]
\fill[blue] (current page.south west) rectangle ($(current page.south east)+(0,7)$);
\fill[white] ($(current page.south west)+(2,2)$) rectangle ($(current page.south west)+(2,2)+(9,3)$);
\fill[white] ($(current page.south east)+(-2,2)$) rectangle ($(current page.south east)+(-2,2)+(-7,3)$);
\end{tikzpicture}
\end{document}
如果您想添加一些文本,您可以使用\node[text width = 9cm, text height = 2.5cm, align = left] at ($(current page.south west)+(6.5,4.5)$) {text goes here};
或类似的内容。