
Мне нужно добавить следующий текст в мой документ Latex. В настоящее время я создал изображение и добавил его в документ.
Мне нужно знать простой способ добавить его в виде текста в мой последний проект.
Дополнительно необходимо расположить его по центру страницы и использовать размер шрифта больше, чем шрифт по умолчанию. (В моем документе текст по умолчанию имеет размер 12 пунктов.) Добавлять границу не нужно.
решение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}