如何在LaTeX中寫出這種彩色文字?

如何在LaTeX中寫出這種彩色文字?

我需要將以下文字新增到我的乳膠文件中。目前我創建了一些圖像並將其添加到文件中。

我需要知道一些簡單的方法將其作為文本添加到我的最新項目中。

另一個需要是將其置於頁面中心並使用大於預設字體的字體大小。 (我的文件預設文字 6e 12pt。)無需新增邊框。

在此輸入影像描述

答案1

像這樣?

\documentclass{article}

\usepackage{xcolor}

\begin{document}

\begin{center}
    \Large\sl
    \textcolor{red}{S}ince \textcolor{red}{E}veryone \textcolor{red}{C}an \textcolor{red}{R}ead, \textcolor{red}{E}ncoding \textcolor{red}{T}ext \textcolor{red}{I}n \textcolor{red}{N}eutral \textcolor{red}{S}entences \textcolor{red}{I}s \textcolor{red}{D}oubtfully \textcolor{red}{E}ffective

    \vspace{1cm}\LARGE\color{red}
    `Secret inside'
\end{center}

\end{document}

答案2

我注意到OP已經接受了迄今為止提供的答案之一。只是為了提供一些多樣性,這裡有一個解決方案,它提供了一個名為的 LaTeX 宏,\boldredcaps該宏將其參數中的所有大寫字母呈現為粗體和紅色自動地。無需\textbf{\textcolor{red}{...}}手動應用大量說明。 LaTeX巨集\boldredcaps依賴Lua強大的gsub字串函數來完成它的工作。

在此輸入影像描述

% !TEX TS-program = lualatex
\documentclass[12pt]{article}
\usepackage{xcolor}   % for "\textcolor" macro
\usepackage{ragged2e} % for "\Centering" macro
\usepackage{luacode}  % for "\luaexec" macro
%% Define a LaTeX macro called "\boldredcaps":
\newcommand\boldredcaps[1]{\luaexec{%
   yyy = "#1"
   yyy = yyy:gsub ( "\%u" , "\\textbf{\\textcolor{red}{\%0}}" )
   tex.sprint ( yyy )
}}

%% Concoct steganographic message:
\newcommand{\blurb}{Since Everyone Can Read, Encoding Text In Neutral Sentences Is Doubtfully Effective.}

\begin{document}

\begin{figure}
\Large  % or "\large", or "\huge", etc
\sffamily\itshape
\Centering
\boldredcaps{\blurb} % <-- argument of \boldredcaps can be a macro 

\bigskip
\textbf{\textcolor{red}{`secret inside'}}
\rmfamily\upshape
\caption{Text Steganography}
\end{figure}

\end{document}

答案3

如果您需要經常執行此操作,可以使用以下命令xstring\StrSubstitute空格替換為自動化\textcolor{red}

在此輸入影像描述

代碼:

\documentclass{article}
\usepackage{xcolor}
\usepackage{xstring}

\newcommand*{\Hightlight}[1]{%
    \noexpandarg
    \StrSubstitute[0]{\textcolor{red}#1}{ }{ \textcolor{red}}[\FormattedString]%
    \FormattedString%
}%

\begin{document}
\Hightlight{Since Everyone Can Read, Encoding Text In Neutral Sentences Is Doubtfully Effective} 
\end{document}

答案4

所提供的代碼應該為您提供所附圖片。它符合你想要的嗎?您可以根據需要調整程式碼。

\documentclass{article}
\usepackage{xcolor}
\usepackage{framed}

\begin{document}
\begin{framed}
\centering
\textbf{\color{red} S}ince \textbf{\color{red} E}veryone \textbf{\color{red} C}an \textbf{\color{red} R}ead, \textbf{\color{red} E}ncoding \textbf{\color{red} T}ext \textbf{\color{red} I}n \textbf{\color{red} N}eutral \textbf{\color{red} S}entences \textbf{\color{red} I}s \textbf{\color{red} D}oubtfully \textbf{\color{red} E}ffective. \\ \vspace{5mm}
{\large \textbf{\color{red} 'Secret inside'}}
\end{framed}
\end{document}

在此輸入影像描述

相關內容