我想更改文档某个部分的颜色。执行此操作的命令是
{\color{red} \section{Introduction}}
(仅仅这样做\section{\color{Introduction}}
不会改变部分编号的颜色)。
因此,当我执行上述命令时,它会稍微调整整个文档中所有文本的垂直空间。这可以在 gif 中观察到https://i.stack.imgur.com/DrWpz.jpg
那么,如何在不改变垂直间距等的情况下进行颜色改变?
编辑:这里可以看到最小的代码片段和改变颜色的效果https://i.stack.imgur.com/GNHjm.jpg(除颜色外无其他变化)
\documentclass{article} % For LaTeX2e
\usepackage{xcolor}
\title{Generative Adversarial Nets}
\begin{document}
\section{Introduction}
The promise of deep learning is to discover rich, hierarchical models that represent
probability distributions over the kinds of data encountered in artificial intelligence applications,
such as natural images, audio waveforms containing speech, and symbols in natural language corpora.
{\color{red} \section{Next Section}}
This framework can yield specific training algorithms for many kinds of model and optimization
algorithm. In this article, we explore the special case when the generative model generates
samples by passing random noise through a multilayer perceptron, and the discriminative model
is also a multilayer perceptron. We refer to this special case as {\em adversarial nets}.
In this case, we can train both models using only
the highly successful backpropagation and dropout algorithms
and sample from the generative
model using only forward propagation. No approximate inference or Markov chains are necessary.
\end{document}
我以前以为罪魁祸首是 nips14submit_e(可以在这里找到(https://pastebin.com/aw96SzXB)),但似乎不是
答案1
正如您所检查的,\showoutput
问题中提供的示例中有和没有间距差异,\color{red}
所以它不是这个问题的示例......
然而问题可能会发生(并且显示在第一个发布的 gif 中,摘要居中)。
一个真实的例子是
\documentclass{article} % For LaTeX2e
\usepackage{xcolor}
\showoutput
\showboxdepth3
\title{Generative Adversarial Nets}
\begin{document}
\begin{center}
zzzzz
\end{center}
{%\color{red}
\section{Next Section}}
This framework can yield specific training algorithms for many kinds of model and optimization
algorithm. In this article, we explore the special case when the generative model generates
samples by passing random noise through a multilayer perceptron, and the discriminative model
is also a multilayer perceptron. We refer to this special case as {\em adversarial nets}.
In this case, we can train both models using only
the highly successful backpropagation and dropout algorithms
and sample from the generative
model using only forward propagation. No approximate inference or Markov chains are necessary.
\end{document}
如果取消注释颜色命令,则会在标题前获得额外的空间,因为颜色 whatsit 节点会阻止部分命令“看到”已经由和添加的垂直空间,因此它会添加其指定的全部空间,而不是合并和\end{center}
指定的空间。\end{center}
\section
诀窍是尽可能在水平而不是垂直模式下进行颜色变化,例如这是有效的
\documentclass{article} % For LaTeX2e
\usepackage{xcolor}
\showoutput
\showboxdepth3
\title{Generative Adversarial Nets}
\begin{document}
\color{red}
\begin{center}
\textcolor{black}{zzzzz}
\end{center}
\section{Next Section}
\mbox{}\color{black}This framework can yield specific training algorithms for many kinds of model and optimization
algorithm. In this article, we explore the special case when the generative model generates
samples by passing random noise through a multilayer perceptron, and the discriminative model
is also a multilayer perceptron. We refer to this special case as {\em adversarial nets}.
In this case, we can train both models using only
the highly successful backpropagation and dropout algorithms
and sample from the generative
model using only forward propagation. No approximate inference or Markov chains are necessary.
\end{document}
或者也许更好的是,下面只是将颜色局部地粘贴到\Large
部分标题所使用的颜色上
\documentclass{article} % For LaTeX2e
\usepackage{xcolor}
\showoutput
\showboxdepth3
\let\realLarge\Large
\title{Generative Adversarial Nets}
\begin{document}
\begin{center}
zzzzz
\end{center}
%\def\Large{\realLarge\color{red}}
\section{Next Section}
%\let\Large\realLarge
This framework can yield specific training algorithms for many kinds of model and optimization
algorithm. In this article, we explore the special case when the generative model generates
samples by passing random noise through a multilayer perceptron, and the discriminative model
is also a multilayer perceptron. We refer to this special case as {\em adversarial nets}.
In this case, we can train both models using only
the highly successful backpropagation and dropout algorithms
and sample from the generative
model using only forward propagation. No approximate inference or Markov chains are necessary.
\end{document}
答案2
我想改变文档某个部分的颜色...一次改变一个部分。
如果您更喜欢使用高级命令并让 LaTeX 在“幕后”为您完成大部分艰苦的工作,同时又不必担心细微的位置变化,我建议您加载包sectsty
并使用其\sectionfont
命令。如以下示例所示,可以\sectionfont{\color{...}}
多次使用。
\documentclass{article}
\usepackage{sectsty} % for "\sectionfont" macro
\usepackage[dvipsnames]{xcolor}
\begin{document}
\sectionfont{\color{RubineRed}}
\section{Introduction}
\sectionfont{\color{Dandelion}}
\section{Literature}
\sectionfont{\color{Aquamarine}}
\section{Data}
\sectionfont{\color{PineGreen}}
\section{Methods}
\sectionfont{\color{NavyBlue}}
\section{Results}
\sectionfont{\color{Violet}}
\section{Conclusion}
\end{document}