关于如何更轻松地将某些笑话嵌入文本中?

关于如何更轻松地将某些笑话嵌入文本中?

我刚刚在 Facebook 页面“Academia Obscura”上发现以下内容:

在此处输入图片描述

这是瑞克·艾斯利 (Rick Astley):永远不会放弃你

显然,这可以通过明智而耐心地选择单词和空格来完成,但这样做需要花费大量时间。我知道可以在 LaTeX 中构建可以轻松做到这一点的东西,但我甚至不知道从哪里开始(可以/应该使用哪些库)。(我正在寻找的确切内容是将某些单词放在文本开头,然后填充其余部分)。

你能给我一些提示吗?只要给我一些指导,我就能一步步进步,永远不会放弃这个项目,永远不会让这个项目失望。

答案1

这是我之前发表评论时想到的两种方法。

\documentclass{article}
\usepackage[T1]{fontenc}

% An environment is good because it keeps these settings local
\newenvironment{jokes}
{\parindent 0pt
 \parfillskip 0pt
 \setlength{\emergencystretch}{.5\textwidth}
}
{}

% The \secret macro
\makeatletter
\newcommand{\secret}{\@ifstar\@secretnonewline\@secretnewline}
\newcommand{\@secretnewline}[1]{\par\textbf{#1}}
\newcommand{\@secretnonewline}[1]{\textbf{#1}}
\makeatother

%\newcommand{\secretbox}[1]{\newline\makebox[\textwidth][s]{#1}}

\usepackage{graphicx}

\makeatletter
\newcommand{\secretbox}{\@ifstar\@secretboxNNL\@secretboxNL}
\newcommand{\@secretboxNL}[1]{\newline
  \resizebox{\textwidth}{\height}{#1}}
\newcommand{\@secretboxNNL}[1]{%
  \resizebox{\dimexpr\textwidth - \parindent\relax}{\height}{#1}}
\makeatother



\begin{document}

Obviously, this could be crafted with a wise and patient selection of
words and spacings but doing so takes a lot of time. I know that it's
possible to build something in LaTeX that could easily do that but I
don't know even where to begin (what libraries could/should be
used). (The exact thing I'm looking is something that put certain
words in the beginning of the text and then fill the rest).

Can you give me some hints? With just a few directions, I could work
my way up and never gonna give this project up, never gonna let this
project down.

\bigskip

% This method requires you to craft your paragraph carefully
\begin{jokes}

  \secret*{Obviously}, this could be crafted with a wise and patient
  selection of words and spacings but doing so takes a lot of time. I
  know that \secret{it's} possible to build something in LaTeX that
  could easily do that but I don't know even where to begin (what
  libraries could/should be used). (The exact thing I'm looking is
  \secret{something} that put certain words in the beginning of the
  text and then fill the rest).

  Can you give me some hints? With just a few directions, I could
  \secret{work} my way up and never gonna give this project up, never
  gonna let this project down.

\end{jokes}

\bigskip

% This one just stretches or shrinks the words in the box so they fit
% on the line
\secretbox*{Obviously, this could be crafted with a wise and patient
  selection of words and} %
\secretbox{spacings but doing so takes a lot of time. I know that it's
  possible to} %
\secretbox{build something in LaTeX that could easily do that but I
  don't know even} %
\secretbox{where to begin (what libraries could/should be used). (The
  exact thing I'm looking is} %
\secretbox{something that put certain words in the beginning of the
  text and then fill the rest).  Can you give me some hints? With just
  a few directions, I} %
\secretbox{could} %
\secretbox{work my way up and never gonna give this project up, never
  gonna let this project down.}

\end{document}

但是,我仍然认为最好的解决方案,无论它是什么,都意味着尝试以这样一种方式编写文本,使得“秘密”首字母缩略词不会使其余文本看起来很荒谬(正如上面[按设计]所做的那样)。

相关内容