将文本写入不连续的区域

将文本写入不连续的区域

不太确定如何最好地描述这一点,所以这里有一张图片:

在此处输入图片描述

本质上,我希望第 1 行和第 2 行假装是一行(换行符正常),第 3 行和第 4 行也是如此。

此外,所有“单元格”都应具有相同的水平和垂直大小,并且如果第 1 行与第 2 行重叠,则文本会对齐(当然,第 3 行和第 4 行也是如此)。

以下是用于生成图像的可怕的代码:

\documentclass{standalone}
\usepackage{tabularx}
\usepackage[english]{babel}
\begin{document}
\begin{tabular}{|p{\dimexpr.1\textwidth}|p{\dimexpr.1\textwidth}|p{\dimexpr.1\textwidth}|p{\dimexpr.1\textwidth}|p{\dimexpr.1\textwidth}|p{\dimexpr.1\textwidth}}
\hline
\parbox{2cm}{This \\ on and} && is some && text & \\
\hline
&\parbox{2cm}{that \\on} && I want && to flow \\
\hline
This && should && be a & \\
\hline
& whole && separate && sentance \\
\end{tabular}
\end{document} 

笔记:虽然我目前正在使用表格,但我很乐意摆脱它并在 Tikz 或其他任何方式中执行此操作。

答案1

flowfram允许在页面上指定文本应流动的框架(块)。以下 MWE 创建一排交错的块,可以根据行/列数和块尺寸进行调整:

在此处输入图片描述

\documentclass{article}
\usepackage{flowfram,multido}% http://ctan.org/pkg/{flowfram,multido}
\usepackage[landscape,margin=1in]{geometry}

\showframebboxtrue% Show blocks
\newlength{\blockwidth}\setlength{\blockwidth}{7\baselineskip}% Block dimensions
\newlength{\blockL}\newlength{\blockB}
\newflowframe{\blockwidth}{\blockwidth}{0pt}{\dimexpr\textheight-\blockwidth}% First block
\multido{\iRow=0+1,\iRowIndex=0+1}{4}{% NUMBER OF ROWS
  % Calculate Base of block
  \setlength{\blockB}{\dimexpr\textheight-\number\numexpr\iRow+1\relax\blockwidth}%
  \multido{\iCol=0+2}{3}{% NUMBER OF COLUMNS
    % Calculate Left edge of block
    \setlength{\blockL}{\dimexpr\iCol\blockwidth}%
    \ifodd\iRowIndex\addtolength{\blockL}{\blockwidth}\fi% Step blocks every other row
    \ifnum\numexpr\iRow+\iCol=0\relax% First block already created
    \else\newflowframe{\blockwidth}{\blockwidth}{\blockL}{\blockB}\fi% Subsequent blocks
  }%
}%

\begin{document}

\raggedright
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis interdum auctor turpis, 
quis condimentum enim sagittis a. Proin congue felis in laoreet dapibus. Suspendisse \framebreak
eu magna et sapien ultricies rhoncus quis a velit. Sed sed nulla tellus. Curabitur 
euismod sem nibh, ut gravida augue vulputate sed. Phasellus quis ante lectus. Proin 
massa ligula, fringilla eu lacinia in, accumsan pharetra sapien. Pellentesque habitant 
morbi tristique senectus et netus et malesuada fames ac turpis egestas. Praesent 
dignissim odio sapien, sed malesuada leo dictum eget. Aliquam erat volutpat. Donec 
scelerisque dictum neque sit amet sagittis.

\end{document}

可以通过 提前从一帧跳转到下一帧\framebreak

\newflowframe{<width>}{<height>}{<x>}{<y>}<width>创建一个尺寸为x 的“流动框架” <height>,其左下角位于 ( <x>, <y>)。

答案2

我觉得你的意思是

在此处输入图片描述

\documentclass{article}

\setlength\textwidth{.5\textwidth}
\usepackage[english]{babel}
\begin{document}



\noindent\parbox[t]{\linewidth}{%
\setlength\baselineskip{2\baselineskip}%
This some  text that I want to flow.
This should  be a  whole  separate  sentence 
This some more  text that I want to flow.
This should  be a  whole  newseparate  sentence}%
\hspace{-\linewidth}%
\raisebox{-\baselineskip}{\parbox[t]{\linewidth}{%
\setlength\baselineskip{2\baselineskip}%
\itshape
Different text that gets stuck in the intervening lines.
Different text that gets stuck in the intervening lines.
Different text that gets stuck in the intervening lines.}}

\end{document} 

第一个猜测

在此处输入图片描述

\documentclass{article}

\setlength\textwidth{.5\textwidth}
\usepackage[english]{babel}
\begin{document}

\renewcommand\baselinestretch{2}

\newcommand\zz[2]{\begin{tabular}[t]{@{}c@{}}#1\\\itshape#2\\\end{tabular}}

\zz{This}{on and}  is some  text \zz{that}{on} I want to flow 
This should  be a  whole  separate  sentence 


\end{document} 

相关内容