文档布局,结合文本和图形面板

文档布局,结合文本和图形面板

这个问题太笼统了,我很难找到直接解决这个问题的存档帖子。

我对使用 LaTeX 设计一张包含图形和少量文本的单面纸张很感兴趣。我脑海中有一个特定的布局,如下所示。我希望能够绘制这些区域,裁剪图形(在图表/徽标中)以适合它们,并放置永远不会超出绘制的边界区域的文本。

输出模型

怎样才能做到这一点?我使用 latex 是因为我正在生成 PDF,并希望循环信息并生成数百个这样的文档。

答案1

您可以使用textpos 包在页面上定位对象(文本和图形)。

答案2

只是作为一个实验,并以答案为基础弗兰克·米特尔巴赫提到斯科特·H的评论,我决定第一次使用xcoffins包,结果如下(显然还有很多改进空间,但它可以作为一个起点):

\documentclass{article}
\usepackage[landscape,paperwidth=19cm]{geometry} 
\usepackage{xcolor} 
\usepackage{xcoffins}
\usepackage{lipsum}

\newlength\GraphWd
\setlength\GraphWd{2.5cm}

\pagestyle{empty}
\definecolor{mycolor}{RGB}{134,34,0}

\begin{document}

% upper coffins
\NewCoffin \result
\NewCoffin \Title
\NewCoffin \Date
\NewCoffin \Logo

% lateral info coffin
\NewCoffin \Info

% 10 small graph coffins
\NewCoffin \Graph
\NewCoffin \Graphi
\NewCoffin \Graphii
\NewCoffin \Graphiii
\NewCoffin \Graphiv
\NewCoffin \Graphv
\NewCoffin \Graphvi
\NewCoffin \Graphvii
\NewCoffin \Graphviii
\NewCoffin \Graphix
\NewCoffin \Graphx

% 1 wider graph coffin
\NewCoffin \LGraph

% filling the coffins
\SetHorizontalCoffin \result {}
\SetHorizontalCoffin \Graph {}

\SetHorizontalCoffin \Title {\Large\bfseries Document title}
\SetHorizontalCoffin \Date {\Large\bfseries Document date}
\SetHorizontalCoffin \Logo {\color{mycolor}\rule{4cm}{2cm}}
\SetVerticalCoffin\Info {4cm} {\noindent\raggedright\lipsum[6]}

\SetHorizontalCoffin \LGraph {\Large\color{mycolor}\rule{\dimexpr5\GraphWd+12pt\relax}{2cm}}

\SetHorizontalCoffin \Graphi {\Large\color{mycolor}\rule{\GraphWd}{\GraphWd}}
\SetHorizontalCoffin \Graphii {\Large\color{mycolor}\rule{\GraphWd}{\GraphWd}}
\SetHorizontalCoffin \Graphiii {\Large\color{mycolor}\rule{\GraphWd}{\GraphWd}}
\SetHorizontalCoffin \Graphiv {\Large\color{mycolor}\rule{\GraphWd}{\GraphWd}}
\SetHorizontalCoffin \Graphv {\Large\color{mycolor}\rule{\GraphWd}{\GraphWd}}
\SetHorizontalCoffin \Graphvi {\Large\color{mycolor}\rule{\GraphWd}{\GraphWd}}
\SetHorizontalCoffin \Graphvii {\Large\color{mycolor}\rule{\GraphWd}{\GraphWd}}
\SetHorizontalCoffin \Graphviii {\Large\color{mycolor}\rule{\GraphWd}{\GraphWd}}
\SetHorizontalCoffin \Graphix {\Large\color{mycolor}\rule{\GraphWd}{\GraphWd}}
\SetHorizontalCoffin \Graphx {\Large\color{mycolor}\rule{\GraphWd}{\GraphWd}}

% put the smaller graph coffins in a 2x5 array inside \Graph
\JoinCoffins \Graph \Graphi
\JoinCoffins \Graph [\Graphi-vc,\Graphi-r] \Graphii[vc,l](3pt,0pt)
\JoinCoffins \Graph [\Graphii-vc,\Graphii-r] \Graphiii[vc,l](3pt,0pt)
\JoinCoffins \Graph [\Graphiii-vc,\Graphiii-r] \Graphiv[vc,l](3pt,0pt)
\JoinCoffins \Graph [\Graphiv-vc,\Graphiv-r] \Graphv[vc,l](3pt,0pt)
\JoinCoffins \Graph [\Graphi-hc,\Graphi-b] \Graphvi[hc,t](0pt,-3pt)
\JoinCoffins \Graph [\Graphvi-vc,\Graphvi-r] \Graphvii[vc,l](3pt,0pt)
\JoinCoffins \Graph [\Graphvii-vc,\Graphvii-r] \Graphviii[vc,l](3pt,0pt)
\JoinCoffins \Graph [\Graphviii-vc,\Graphviii-r] \Graphix[vc,l](3pt,0pt)
\JoinCoffins \Graph [\Graphix-vc,\Graphix-r] \Graphx[vc,l](3pt,0pt)

% put the wider graph below \Graph
\JoinCoffins \Graph[hc,b]  \LGraph[hc,t](0pt,-15pt)

%  put the upper coffins into \result
\JoinCoffins \result \Title
\JoinCoffins \result[\Title-b,\Title-l]  \Date [t,l](0pt,-8pt)
\JoinCoffins \result [vc,l]  \Logo [vc,r](\textwidth,0pt)
% add the \info coffin to \result
\JoinCoffins \result [b,l] \Info [t,l](10pt,-\baselineskip)

% add the \Graph coffin to \result
\JoinCoffins \result [\Info-t,\Info-r] \Graph [t,l](40pt,-1.5\baselineskip)

\noindent\TypesetCoffin \result

\end{document}

在此处输入图片描述

xcoffins确实是一个很好的包裹。

答案3

在上下文中,图层经常用于将素材放置在页面的特定位置。例如,您要寻找的布局可以按以下方式实现。

\setuppapersize[A5,landscape]
\setuppagenumbering[location=] % No page numbering

\useMPlibrary[dum] % For placeholder pictures

\definelayer
  [header]
  [
    x=2mm,
    y=2mm,
  ]

\definelayer
  [info]
  [
    x=5mm,
    y=\the\dimexpr0.2\paperheight+15mm,
  ]

\definelayer
  [graph]
  [
    x=\the\dimexpr0.3\paperwidth-10mm,
    y=\the\dimexpr0.85\paperheight-5mm,
  ]

\definelayer
  [grid]
  [
    x=\the\dimexpr0.3\paperwidth-10mm,
    y=\the\dimexpr0.2\paperheight+15mm,
  ]

\setupbackgrounds[page][background={header, info, graph, grid}]

\setlayerframed
  [header]
  [
    width=\the\dimexpr\paperwidth-4mm,
    height=0.2\paperheight,
  ]
  {Document header}

\setlayerframed
  [info]
  [
    width=0.2\paperwidth,
    height=\the\dimexpr0.6\paperheight-5mm,
    align={flushleft, hyphenated},
  ]
  {Information about the content}

\setlayer
  [graph]
  {\externalfigure[dummy][width=0.7\paperwidth, height=0.1\paperheight]}


\def\GRAPH
    {\externalfigure[dummy]
                    [
                      width=\the\dimexpr0.1\paperwidth-0.4mm,
                      height=\the\dimexpr0.2\paperheight-0.5mm,
                    ]}
\setlayerframed
  [grid]
  [
    width=0.7\paperwidth,
    height=0.5\paperheight,
    %frame=off,
  ]
  {
    \startTABLE[offset=1mm]
      \NC \GRAPH \NC \GRAPH \NC \GRAPH \NC \GRAPH \NC \GRAPH \NC \NR
      \NC \GRAPH \NC \GRAPH \NC \GRAPH \NC \GRAPH \NC \GRAPH \NC \NR
    \stopTABLE
  }

\starttext

% Insert an empty page, with only the background layers.
\null

\stoptext

这使

在此处输入图片描述

答案4

我必须说,在显眼的面板中组装图表最好使用wrapfig。让徽标在顶部对齐很困难,但我发现该软件包fancyhdr效果非常好,只需要以下一行:

\fancyheader[R]{\includegraphics{logo.jpg}}

相关内容