如何自動在自動換行後開始的每一行前面新增空格?

如何自動在自動換行後開始的每一行前面新增空格?

我需要的是文檔中的第一行以及明確指定的中斷(\\) 後面的每一行,使其第一個字元和頁面左邊距之間有0 毫米空格(無空格)(這是預設行為) ,而每個由 TeX 隱式啟動的中斷(由於到達頁面的右邊距)後面的行以空格(第一個字元和頁面的左邊距之間)開始,該空格比前一行的空格大 10 毫米。

1234567890123456789012345678901234567 <- 37 characters before auto-wrap
This is very first line with no space
 while this is second line after
  automatic break.\\
This line also doesn't begin with
 space but this one does.

答案1

空行比 更清晰\\

這是一種方法,使用\parshape

\documentclass[twocolumn]{article}

\usepackage{xparse}

\ExplSyntaxOn

\NewDocumentEnvironment{bizarre}{O{\columnwidth}}
 {
  \par
  \setlength{\parindent}{0pt}
  \bp_make_parshape:n { #1 }
  \everypar{\parshape 50~\l_bp_parshape_tl}
 }
 {
  \par
 }

\tl_new:N \l_bp_parshape_tl
\dim_new:N \l_bp_parshape_dim

\cs_new:Nn \bp_make_parshape:n
 {
  \dim_set:Nn \l_bp_parshape_dim { #1 }
  \tl_set:Nx \l_bp_parshape_tl
   {
    \int_step_function:nN { 50 } \__bp_parshape:n
   }
 }
\cs_new:Nn \__bp_parshape:n
 {
  \dim_eval:n { 10mm*(#1-1) } ~
  \dim_eval:n { \l_bp_parshape_dim - 10mm*(#1-1) }
 }

\ExplSyntaxOff

\begin{document}

\begin{bizarre}
This is very first line with no space
 while this is second line after
  automatic break.

This line also doesn't begin with
 space but this one does.
\end{bizarre}

\begin{bizarre}[0.8\columnwidth]
This is very first line with no space
 while this is second line after
  automatic break.

This line also doesn't begin with
 space but this one does.
\end{bizarre}

\end{document}

在此輸入影像描述

相關內容