我最近看到一份由 Adobe Photoshop PDF 创建的文档。我在这里用 LaTeX 模仿了它的基本视觉结构:
我的问题是关于彩色的底层部分:
- 我用了(未调整、未重构)使用 Tikz 创建它们
- 它们可以是任何东西,即不仅仅是突出显示一行文本
- 任何尺寸、位置、重叠,(最好有:形状) ETC。
如何使用更“经典”的 LaTeX 方式实现这样的视觉效果,即不使用 Tikz?
例如\makebox{0cm}{ }
,\raisebox
和\vspace{-1cm}
类似的似乎没有提供必要的覆盖和透明度,至少在我看来是这样。
\documentclass[10pt,a4paper]{article}
\usepackage{tikz}
\parindent0pt
\begin{document}
\begin{center}
\begin{tikzpicture}[
h1/.style={font={\huge\bfseries}},
h2/.style={font={\Large}},
]
\node[fill=green!40!gray!40,
minimum width=.6\textwidth,
minimum height=13mm] at (0,1) {};
\node[h1] at (0,1.5) {Some Title /};
\node[h1] at (0,0.5) {Title continued};
\node[h2] at (0,-.3) {Some Subheader};
\end{tikzpicture}
\end{center}
Text, which introduces the topic. \dots
\begin{center}
\begin{tikzpicture}[
h3/.style={font={\large\bfseries}},
]
\node[fill=orange!80!red!20,
minimum width=1\textwidth,
minimum height=6mm] at (0,1) {};
\node[h3] at (0,1.3) {What can be done about this?};
\end{tikzpicture}
\end{center}
Some more text, and:
\begin{itemize}
\item some issues
\item some remarks
\item additional information
\end{itemize}
\end{document}
答案1
您可以使用彩色的\rule
s。至少,您可以使用这种方法创建简单的矩形。如果您在排版文本之前排版它们,则不会遇到透明度问题(毕竟,您在原始代码中也将彩色节点放在排版文本之前)。当然,这需要进行一些调整才能正确放置,但我想只要有一点数学知识,这应该是完全可行的:
\documentclass[10pt,a4paper]{article}
\usepackage{xcolor}
\parindent0pt
\begin{document}
\begin{center}
\vspace*{-1\baselineskip}
\makebox(\textwidth,0pt){\raisebox{-4cm}{\textcolor{green!40!gray!40}{\rule{.6\textwidth}{13mm}}}}
{\huge\bfseries Some Title / \\[10pt] \huge\bfseries Title continued \par}
\vspace*{0.2cm}
{\Large Some Subheader \par}
\end{center}
Text, which introduces the topic. \dots
\begin{center}
\vspace*{-1\baselineskip}
\makebox(\textwidth,0pt){\raisebox{-1.8cm}{\textcolor{orange!80!red!20}{\rule{\textwidth}{6mm}}}}
{\large\bfseries What can be done about this? \par}
\vspace*{0.2cm}
\end{center}
Some more text, and:
\begin{itemize}
\item some issues
\item some remarks
\item additional information
\end{itemize}
\end{document}
如果你需要其他形状,你也可以看看相对较新的l3draw
包裹它具有相当惊人的绘制功能。我猜它比 Ti 轻量得多钾Z:
\documentclass[10pt,a4paper]{article}
\usepackage{l3draw}
\parindent0pt
\ExplSyntaxOn
\NewDocumentCommand{\drawPathEllipse}{ m m m m }{
\vbox_set:Nn \l_tmpa_box {
\draw_begin:
\color_fill:n { #1 }
\draw_path_ellipse:nnn { 0cm , 0cm } { #3 , 0cm } { 0cm , #4 }
\draw_path_use_clear:n { fill }
\draw_end:
}
\box_set_ht:Nn \l_tmpa_box { #2 }
\box_set_dp:Nn \l_tmpa_box { 0pt }
\box_use:N \l_tmpa_box
}
\ExplSyntaxOff
\begin{document}
\begin{center}
\drawPathEllipse{green!40!black!20}{-0.25cm}{4cm}{1cm}
{\huge\bfseries Some Title / \\[10pt] \huge\bfseries Title continued \par}
\vspace*{0.2cm}
{\Large Some Subheader \par}
\end{center}
Text, which introduces the topic. \dots
\begin{center}
\drawPathEllipse{yellow!40!red!20}{-0.1cm}{5cm}{0.5cm}
{\large\bfseries What can be done about this? \par}
\end{center}
Some more text, and:
\begin{itemize}
\item some issues
\item some remarks
\item additional information
\end{itemize}
\end{document}