我有以下文档布局,由两列文本(这里只有左列有一些文本)、文档左列上的灰色背景条纹和整个页面边框处的黄色框架组成:
\documentclass[a4paper]{article}
\usepackage[a4paper,
left = 0.2cm,
right = 0.2cm,
top = 0.1cm,
bottom = 0.2cm]{geometry}
\usepackage{paracol}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{tikz}
\backgroundcolor{c[0](5pt,3pt)(0.5\columnsep,3pt)}[rgb]{0.95,0.95,0.95}
\begin{document}
% Yellow frame
% https://tex.stackexchange.com/questions/452538/how-to-insert-a-frame-for-a-page-in-latex
\tikz[overlay, remember picture] \draw[draw=yellow,line width=0.7cm] ([xshift=0cm,yshift=-0cm]current page.north west) rectangle ([xshift=-0cm,yshift=0cm]current page.south east);
% 2-column text
\columnratio{0.4}
\begin{paracol}{2}
\lipsum[1-3]
% \switchcolumn
\lipsum[2-6]
\end{paracol}
但我想将文本作为第一层/顶层,黄色框作为第二层/中间层,灰色背景作为第三层/底层,如下图所示(使用 power point 制作):
如何按照描述的顺序使这三个层之间实现重叠?
答案1
我的尝试……
\documentclass[a4paper]{article}
\usepackage[a4paper,
left=0.2cm,
right=0.2cm,
top=0.1cm,
bottom=0.2cm]{geometry}
\usepackage{paracol}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{tikz}
\begin{document}
% Yellow frame first on bottom layer
\begin{tikzpicture}[remember picture,overlay]
\draw[draw=yellow,line width=0.7cm] ([xshift=0cm,yshift=-0cm]current page.north west) rectangle ([xshift=-0cm,yshift=0cm]current page.south east);
\end{tikzpicture}
% Gray background in second layer <= Adjust the dimensions and position to fit your layout
\begin{tikzpicture}[remember picture,overlay]
\fill[gray!30] (0.2cm,-0.1cm) rectangle (\textwidth-0.4cm,-\textheight+0.3cm); % Adjust these dimensions
\end{tikzpicture}
% your text content finally so it appears on top
\columnratio{0.4}
\begin{paracol}{2}
\lipsum[1-3]
\lipsum[2-6]
\end{paracol}
\end{document}
答案2
已编辑:@samcarter_is_at_topanswers.xyz 在后续问题中接受的答案“tikzpicture 移动文本“,这就是我所寻找的。也非常感谢@JeT 的第一次出色提示和尝试!
谢谢@JeT,很接近...黄色框架与灰色背景切换了..
\documentclass[a4paper]{article}
\usepackage[a4paper,
left=0.2cm,
right=0.2cm,
top=0.1cm,
bottom=0.2cm]{geometry}
\usepackage{paracol}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{tikz}
\begin{document}
% Gray background at the bottom
\begin{tikzpicture}[remember picture,overlay]
\fill[gray!30] ([xshift=0cm,yshift=-0cm]current page.north west) rectangle ([xshift=-12.5cm,yshift=0cm]current page.south east); % Adjust these dimensions
\end{tikzpicture}
% Yellow frame as a second layer
\begin{tikzpicture}[remember picture,overlay]
\draw[draw=yellow,line width=0.7cm] ([xshift=0cm,yshift=-0cm]current page.north west) rectangle ([xshift=-0cm,yshift=0cm]current page.south east);
\end{tikzpicture}
% Text on top
\columnratio{0.4}
\begin{paracol}{2}
\noindent\lipsum[1-3]
\noindent\lipsum[2-6]
\end{paracol}
\end{document}
但是,仍然存在如何使 lipsum 的文本从左上角开始的问题...事实上,它看起来像是将tikzpicture
文本向下移动...
(我尝试了几次,但无法解决这个问题 - 因此我打开了一个新问题)