按照手机文本的样式排版

按照手机文本的样式排版

我想在“传统”文本文档中包含一个环境,该环境模仿手机上基本文本的图形样式:作者 1 文本向左调整,位于带圆角的红色块上;作者 2 文本向右调整,位于带圆角的绿色块上,等等。语法类似于以下内容:

\begin{phonetext}
\authorleft{my text}
\authorright{your text}
\authorleft{my next text}
\end{phonetext}

理想的情况是能够选择背景颜色(例如左边是红色,右边是绿色)和其他字体大小及相关信息。

我不需要包含照片、视频帧、录音图标、发布日期和时间等功能,但也许其他人会使用这样的选项。

答案1

在此处输入图片描述

\documentclass{article}
\usepackage{tcolorbox,varwidth}

\newenvironment{phonetext}{}{}

\newcommand\authorleft[1]{%
\begin{flushleft}\tcbox[colback=blue!50]{%
\begin{varwidth}{.7\textwidth}\raggedright#1\end{varwidth}}%
\end{flushleft}%
}
\newcommand\authorright[1]{%
\begin{flushright}\tcbox[colback=red!50]{%
\begin{varwidth}{.7\textwidth}\raggedleft#1\end{varwidth}}%
\end{flushright}%
}

\begin{document}
\begin{phonetext}
\authorleft{my text}
\authorright{your text}
\authorleft{my next text}
\authorright{your text
your textyour textyour textyour textyour textyour text
your textyour textyour textyour textyour textyour text
}
\end{phonetext}
\end{document}

相关内容