设置页面元素的布局

设置页面元素的布局

我是 ConTEXt 的新手,我正在尝试设置页面上元素的布局。基本上,我想要的是将一些图片和表格放在页面上的特定位置。下面是我想要的典型布局的草图。

页面上一些元素的布局

我该怎么做?我尝试了很多办法,但都没有奏效

已编辑

在 latex 中,我可以使用 minipages 轻松获得此布局。例如:

\documentclass[a4paper]{article}
\usepackage{graphicx}
\usepackage{geometry}

\geometry{a4paper,left=2cm,right=2cm,top=1.5cm,bottom=1.5cm,nohead}
\setlength\parindent{0cm}

\begin{document}

\fbox{
 \begin{minipage}{.75\textwidth}
  \fbox{
   \begin{minipage}{.1\textwidth}
     \includegraphics[width=\textwidth]{../card.png}
   \end{minipage}
  }
  \fbox{
   \begin{minipage}{.8\textwidth}
     \centering
     Lorem Ipsum

     Neque porro quisquam est qui dolorem
   \end{minipage}
  }
 \fbox{
  \begin{minipage}{.95\textwidth}
 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras luctus     augue augue, vitae vulputate ligula mattis vel. Praesent efficitur massa et neque vehicula, quis ultricies mi vestibulum. Donec facilisis, nibh eu mollis consectetur, justo elit faucibus leo, ut viverra dolor ante sit amet lorem
  \end{minipage}
}
 \end{minipage}
}
\fbox{
 \begin{minipage}{.2\textwidth}
 \begin{tabular}{c|c}
   Lorem & Ipsum\\ \hline
   Lorem & Ipsum\\ \hline
   Lorem & Ipsum\\ \hline
   Lorem & Ipsum\\ \hline
   Lorem & Ipsum\\ \hline
 \end{tabular}
\end{minipage}
}

\fbox{
\begin{minipage}{\textwidth}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras luctus augue augue, vitae vulputate ligula mattis vel. Praesent efficitur massa et neque vehicula, quis ultricies mi vestibulum. Donec facilisis, nibh eu mollis consectetur, justo elit faucibus leo, ut viverra dolor ante sit amet lorem
\end{minipage}
}

\end{document}

生产:

在此处输入图片描述

所以,我的问题是:有没有办法使用上下文来模拟这种布局,以便我的布局自动调整,就像在乳胶示例中一样?

答案1

LaTeX 有\fboxminipage。ConTeXt 有(功能更强大)\framed(及其配套产品\start...\stopframed)。您必须设置align=normal才能获得常规换行。

\setupframed[offset=5pt]

\starttext

\noindent % leave vertical mode
\startframed[align=normal,width=.75\textwidth,location=lohi]
  \externalfigure[cow][width=.1\hsize,frame=on,location=lohi]
  \startframed[align=middle,width=.8\hsize,location=lohi]
    Lorem Ipsum

    Neque porro quisquam est qui dolorem
  \stopframed

  \startframed[align=normal,width=.95\hsize]
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras
    luctus augue augue, vitae vulputate ligula mattis vel. Praesent
    efficitur massa et neque vehicula, quis ultricies mi
    vestibulum. Donec facilisis, nibh eu mollis consectetur, justo
    elit faucibus leo, ut viverra dolor ante sit amet lorem
  \stopframed
\stopframed
\quad
\startframed[align=normal,width=.2\textwidth,location=lohi]
  \starttabulate[|c|c|]
    \NC Lorem \NC Ipsum \NC\NR\HL
    \NC Lorem \NC Ipsum \NC\NR\HL
    \NC Lorem \NC Ipsum \NC\NR\HL
    \NC Lorem \NC Ipsum \NC\NR\HL
    \NC Lorem \NC Ipsum \NC\NR\HL
  \stoptabulate
\stopframed
\par\noindent
\startframed[align=normal,width=\textwidth]
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras luctus
  augue augue, vitae vulputate ligula mattis vel. Praesent efficitur
  massa et neque vehicula, quis ultricies mi vestibulum. Donec
  facilisis, nibh eu mollis consectetur, justo elit faucibus leo, ut
  viverra dolor ante sit amet lorem
\stopframed

\stoptext

在此处输入图片描述


下面的内容看起来很糟糕,但应该可以让您很好地了解如何在页面上绝对定位内容。

\starttext

\definelayer[overlay]

\setlayerframed
  [overlay]
  [x=3cm,y=1cm,width=7cm]
  {Lorem ipsum}

\setlayerframed
  [overlay]
  [x=11cm,y=0cm,width=4cm]
  [align=normal,width=4cm]
  {\starttabulate[|r|l|]
     \HL
     \NC c \NC centered      \NC \AR
     \NC l \NC left aligned  \NC \AR
     \NC r \NC right aligned \NC \AR
     \HL
   \stoptabulate
   \blank
   \input ward\par}

\setlayerframed
  [overlay]
  [x=0cm,y=3cm,width=10cm]
  [align=normal,width=10cm]
  {\input zapf\par}

\setlayerframed
  [overlay]
  [x=0cm,y=10cm,width=\textwidth]
  [align=normal,width=\textwidth]
  {\input knuth\par}

\setlayer
  [overlay]
  [x=0cm,y=0cm,width=2cm,height=2cm]
  {\externalfigure[cow][width=2cm]}

\flushlayer[overlay]

\stoptext

在此处输入图片描述

相关内容