文件佈局,結合文字和圖形面板

文件佈局,結合文字和圖形面板

這是一個非常普遍的問題,我無法輕易找到直接解決該問題的存檔貼文。

我有興趣使用 LaTeX 設計一張包含圖形和少量文字的單面紙。我心中有一個具體的佈局,如下所示。我希望能夠繪製這些區域,裁剪圖形(在圖形/徽標中)以適合它們,並放置永遠不會超出繪製的邊界區域的文字。

輸出模擬

怎樣才能做到這一點呢?我正在使用 Latex,因為我正在生成 PDF,並希望循環資訊並生成數百個此類文件。

答案1

您可以使用文字POS包在頁面上定位物件(文字和圖形)。

答案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}}

相關內容