文本的放置:这可行吗?

文本的放置:这可行吗?

只要指定文本开始的插入点,就可以将文本放置在页面的任何位置。

是否可以控制文本的位置,以便用户指定扩展的结束位置。

例如,在下面的代码中,是否可以这样放置文本,使得对于页面来说,文本从水平中心开始结束在文本框的最后一行末尾。在下面的草图中,粉红色区域表示文本应位于的位置。它从粉红色框的左上角开始,文本的最后一行是页面文本框的底部。(所以不知道文本应该从哪里垂直开始;LaTeX 引擎或其他引擎应该计算这一点。

在此处输入图片描述

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[10pt]{book}
\usepackage[
    showframe,%
    paperwidth=30pc,%
    paperheight=48pc,%
    margin=2pc,%
]{geometry}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[american]{babel}
\usepackage{microtype}
\usepackage{libertine}
\usepackage{lipsum}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{My chapter}

\lipsum[1]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

答案1

我过去常常\vfill将它推到底部,\hfill将它推到右边,并将它放置在minipage对齐的[b]位置以产生所需的宽度。

\documentclass[10pt]{book}
\usepackage[
    showframe,%
    paperwidth=30pc,%
    paperheight=48pc,%
    margin=2pc,%
]{geometry}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[american]{babel}
\usepackage{microtype}
\usepackage{libertine}
\usepackage{lipsum}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{My chapter}
\vfill\hfill
\begin{minipage}[b]{.5\textwidth}
\lipsum[1]
\end{minipage}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}

在此处输入图片描述

答案2

解决方案如下eso-pic

\documentclass[10pt]{book}
\usepackage[
    showframe,%
    paperwidth=30pc,%
    paperheight=48pc,%
    margin=2pc,%
]{geometry}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[american]{babel}
\usepackage{microtype}
\usepackage{libertine}
\usepackage{eso-pic, hanging} 
\usepackage{lipsum}

\begin{document}

\chapter{My chapter}
\hangpara{-0.52\textwidth}{6}
\lipsum[1]
 \AddToShipoutPictureFG*{\AtTextLowerLeft{\hspace*{0.5\linewidth}\parbox[b]{0.5\textwidth}{\color{red}\lipsum[1]}}}

\end{document} 

在此处输入图片描述

相关内容