非矩形车身几何形状

非矩形车身几何形状

我喜欢排版文档,让内边距遵循弯曲的路径。例如,像下面的这个(在 Scribus 中完成)。

我尝试将文本环绕在适当位置的弯曲图像上,但显然没有起作用,因为图像总是矩形的,对吗?

我检查了包的文档,geometry看是否可以定义一个\rightmargin依赖于其他变量(如行号)的变量,但我没有找到任何东西。

在 Google 和 tex.stackexchange 中搜索任意数量的相关术语组合均无结果。

我已准备好使用luatex或其他(理想情况下,我也想使用microtype)。任何帮助都非常感谢!

编辑:理想情况下,除了给出“曲线”边距的初始形状外,该解决方案不需要手动调整。事实上,我想将它用于大约 60 页的小书。\shapepar(或\cutout,甚至\parshape就此而言)的问题在于,它必须针对每个段落进行微调,事先知道文本的长度和段落在页面上的位置(此外,跨两页的段落似乎很难处理)。

在此处输入图片描述

答案1

此版本尝试考虑各部分所占用的垂直空间;甚至可能适用于图形、表格等...(未经测试)。

正弦边距第 1 页 正弦边距第 2 页 正弦边距第 3 页 正弦边距 第 4 页

\documentclass[a4paper]{article}

\def\LINESPERPAGE{45}
\usepackage[textheight=\LINESPERPAGE\baselineskip]{geometry}

\usepackage{lipsum}
\usepackage{xinttools}% requires version 1.09m or later

% \edef\MOCKSINE {%
% {0pt \the\dimexpr\textwidth-3em}%
% {0pt \the\dimexpr\textwidth-4em}%
% {0pt \the\dimexpr\textwidth-5em}%
% {0pt \the\dimexpr\textwidth-5.75em}%
% {0pt \the\dimexpr\textwidth-6em}%
% {0pt \the\dimexpr\textwidth-5.75em}%
% {0pt \the\dimexpr\textwidth-5em}%
% {0pt \the\dimexpr\textwidth-4em}%
% {0pt \the\dimexpr\textwidth-3em}%
% {0pt \the\dimexpr\textwidth-2em}%
% {0pt \the\dimexpr\textwidth-1em}%
% {0pt \the\dimexpr\textwidth-0.25em}%
% {0pt \the\dimexpr\textwidth-0em}%
% {0pt \the\dimexpr\textwidth-0.25em}%
% {0pt \the\dimexpr\textwidth-1em}%
% {0pt \the\dimexpr\textwidth-2em}%
% }

% let's divide by two the sizes of the undulation.
\edef\MOCKSINE {%
{0pt \the\dimexpr\textwidth-1.5em}%
{0pt \the\dimexpr\textwidth-2em}%
{0pt \the\dimexpr\textwidth-2.5em}%
{0pt \the\dimexpr\textwidth-2.875em}%
{0pt \the\dimexpr\textwidth-3em}%
{0pt \the\dimexpr\textwidth-2.875em}%
{0pt \the\dimexpr\textwidth-2.5em}%
{0pt \the\dimexpr\textwidth-2em}%
{0pt \the\dimexpr\textwidth-1.5em}%
{0pt \the\dimexpr\textwidth-1em}%
{0pt \the\dimexpr\textwidth-.5em}%
{0pt \the\dimexpr\textwidth-0.125em}%
{0pt \the\dimexpr\textwidth-0em}%
{0pt \the\dimexpr\textwidth-0.125em}%
{0pt \the\dimexpr\textwidth-.5em}%
{0pt \the\dimexpr\textwidth-1em}%
}


\makeatletter

\edef\MCK@LINESPERPAGE {\the\numexpr \LINESPERPAGE\relax }

\def\MCK@LINECOUNT {0}

\def\SETUPPARSHAPE {%
  \xdef\MCK@tmpB {\the\numexpr \pagetotal/\baselineskip}%
  \ifnum\MCK@tmpA>\MCK@tmpB
  % assume we are on a new page. !!!Something more robust should be done here!!!
  \xdef\MCK@LINECOUNT
   {\the\numexpr\MCK@LINECOUNT+\MCK@tmpB-\MCK@tmpA+\MCK@LINESPERPAGE}%
  \else
  \xdef\MCK@LINECOUNT {\the\numexpr\MCK@LINECOUNT+\MCK@tmpB-\MCK@tmpA}%
  \fi
  \global\let\MCK@tmpA\MCK@tmpB   
  \edef\STARTINDEX {\the\numexpr\MCK@LINECOUNT+16-16*((\MCK@LINECOUNT+8)/16)}%
  \parshape 16 \xintListWithSep { }{\xintTrim \STARTINDEX\MOCKSINE}
               \xintListWithSep { }{\xintKeep \STARTINDEX\MOCKSINE} \relax
}

\def\STARTUNDULATIONS {\def\MCK@LINECOUNT {0}\def\MCK@tmpA {0}%
    \def\par {\oldpar \SETUPPARSHAPE }\SETUPPARSHAPE }
\def\STOPUNDULATIONS {\let\par\oldpar }
\makeatother

\let\oldpar\par
\AtBeginDocument {\STARTUNDULATIONS }

\begin{document}

\newcount\cnta
\cnta1
\loop

\section{This is a section}
\lipsum [\cnta-\numexpr\cnta+3\relax]
\section{This is another section}
\lipsum [\numexpr\cnta+3\relax-\numexpr\cnta+7\relax]

\advance\cnta 8
\ifnum\cnta < 50
\repeat
\end{document}


第一个答案

前两页:

正弦边距 第 1 页 正弦边距第 2 页

我猜几乎任何东西都会破坏它。而且\everypar我担心它经常被覆盖,所以无法使用。

\documentclass{article}
% \usepackage[english]{babel}
% \usepackage{blindtext}
\usepackage{lipsum}
\usepackage{xinttools}% requires version 1.09m or later

\edef\MOCKSINE {%
{0pt \the\dimexpr\textwidth-3em\relax}%
{0pt \the\dimexpr\textwidth-4em\relax}%
{0pt \the\dimexpr\textwidth-5em\relax}%
{0pt \the\dimexpr\textwidth-5.75em\relax}%
{0pt \the\dimexpr\textwidth-6em\relax}%
{0pt \the\dimexpr\textwidth-5.75em\relax}%
{0pt \the\dimexpr\textwidth-5em\relax}%
{0pt \the\dimexpr\textwidth-4em\relax}%
{0pt \the\dimexpr\textwidth-3em\relax}%
{0pt \the\dimexpr\textwidth-2em\relax}%
{0pt \the\dimexpr\textwidth-1em\relax}%
{0pt \the\dimexpr\textwidth-0.25em\relax}%
{0pt \the\dimexpr\textwidth-0em\relax}%
{0pt \the\dimexpr\textwidth-0.25em\relax}%
{0pt \the\dimexpr\textwidth-1em\relax}%
{0pt \the\dimexpr\textwidth-2em\relax}%
}

\def\LINECOUNT {0}

\def\SETUPPARSHAPE {%
 \xdef\LINECOUNT  {\the\numexpr\LINECOUNT+\prevgraf}%
 \edef\STARTINDEX {\the\numexpr\LINECOUNT+16-16*((\LINECOUNT+8)/16)}%
 \parshape 16 \xintListWithSep { }{\xintTrim \STARTINDEX\MOCKSINE}
              \xintListWithSep { }{\xintKeep \STARTINDEX\MOCKSINE} \relax
}


\let\oldpar\par
\AtBeginDocument {\def\par {\oldpar \SETUPPARSHAPE }

\begin{document}
\SETUPPARSHAPE 
\lipsum [1-20]
\end{document}

% problems with \blindtext
% \blindtext [10]
% I don't know why.

相关内容