当前位于:ChinaTeX > TeX 使用指南
常见问题(二)


翻译/ 整理:happytex

1。怎样在多栏环境中使用单栏图表?
答:如果你在多栏环境中使用 \begin{figure} ... \end{figure}, 图形是不会出现的。如果你用另外的命令 \begin{figure*} ... \end{figure*}, 图形就会超出右边或有页的上边。解决的方法是把下面命令放在 \begin{document}前面

\makeatletter
\newenvironment{tablehere}
{\def\@captype{table}}
{}

\newenvironment{figurehere}
{\def\@captype{figure}}
{}
\makeatother
然后用 figurehere 和 tablehere 在你平常用 figure[h....] 和 table[h...]的地方。
2。怎样得到度(degree)的符号?

答:在\begin{document} 前面用 \newcommand{\grad}{\ensuremath{^{\circ}}} ,然后你在文中就可用 45\grad等等了。

3。怎样得到一个欧元符号?

答:用\usepackage{textcomp} 和 \texteuro 或 \usepackage{marvosym} 和 \EUR都可以。

4。当我应用fancyhdr时,我得到了太多'Overfull \vbox' 的信息?

答:这是因为缺省的标题空间太小的原因(文本的一行),不能包括fancy标题(1 line of text + 1 rule)。在导言里面加\addtolength{\headheight}{2.5pt}即可。

5。当我用 fancyhdr时,左边和右边的题有交叉重合?
答:这是因为\section 等命令中的文本太长的原因,可用类似"\section[short version]{very long version indeed}"来解决问题。

6。怎样从两栏页面中得到单栏的标题和摘要?

答:试试Donald Arseneau的

\documentclass{article}
....
\begin{document}
\twocolumn[
\begin{@twocolumnfalse}
\maketitle
\begin{abstract}
...
\end{abstract}
\end{@twocolumnfalse}
]

7。怎样改变只有几行文本的页边距?
答:把以下命令放在\begin{document}前面
\newenvironment{narrow}[2]{%
\begin{list}{}{%
\setlength{\topsep}{0pt}%
\setlength{\leftmargin}{#1}%
\setlength{\rightmargin}{#2}%
\setlength{\listparindent}{\parindent}%
\setlength{\itemindent}{\parindent}%
\setlength{\parsep}{\parskip}%
}%
\item[]}{\end{list}}

然后 \begin{narrow}{1.0in}{0.5in} ... \end{narrow} 就产生了左边缩小1.0 英寸 和右边缩小 0.5 英寸的效果
8。我的文本在开始时就停止不编译?

答:这是因为每一次文本编译时都有对应的*.aux文件(前一次产生的),所以删去这个文件重新编译即可。

9。在eps上加公式的另一个方法。

答:1)建一个eps图形;

2)在你所想放置的地方写下文本(如公式);

3)在latex文本中用命令 \usepackage{psfrag} ;

4)用命令 \psfrag{formula}{some text $\sum_1^\infty \int \frac{a^2}{b_i}$ }让latex为做工作。

例如
\documentclass[12pt]{article}
\usepackage{psfrag}
\usepackage{epsfig}

\begin{document}
\begin{figure}
\begin{center}
\psfrag{formula1}{some text $\sum_1^\infty \int \frac{a^2}{b_i}$}
\psfrag{formula2}{other text $\int_0^{\frac{a^2}{b}} \sqrt{c}$}
\epsfig{file=example.eps, width=12cm}
\end{center}
\caption{The example figure}
\label{exampl}
\end{figure}
\end{document}

10。怎样把一个大表格横向放置?

答:用宏包\usepackage{rotating},然后变换
\begin{table}
....
\end{table}

\begin{sidewaystable}
....
\end{sidewaystable}

注意这个旋转很可能在你的预览中不会再现。

11。关于itemize。

答: 清单至多有四级

$\bullet$ - \labelitemi
\textbf{ --} - \labelitemii
$\ast$ - \labelitemiii
$\cdot$ - \labelitemiv
你可重新定义
\def{\labelitemi}{$\spadesuit$}
\renewcommand{\labelitemi}{$\spadesuit$}

也可在itemize 环境中\item命令中同时拥有不同的标签

\begin{itemize}
\item[$\heartsuit$] ...
\item[$\diamondsuit$] ...
\item[$\clubsuit$] ...
\end{itemize}

数字序列至多四级顺序可显示,如

1,2 ... - \enumi
(a), (b) ... - \enumii
i,ii,... - \enumiii
A., B. ... - \enumiv

你也可指明选项,如
\begin{enumerate}
\item[(1)]
\item[(2)] ...
\end{enumerate}

12。我怎样重新定义items之间的距离?

答:用miktex2.1中的mdwlist宏包,也可从CTAN的macros/latex/contrib/supported/mdwtools.zip 上下载后。

13。怎样改变行距?

答:用doublespace宏包,参数"coef"是\baselinestretch文本中定义数值,则可用命令

\begin{spacing}{coef} % coef=2 时双倍行距了
... text
\end{spacing}

14。 怎么定义一个定理型环境?

答:用theorem宏包,例子:

\newtheorem{howto}{Questions}[section]
\theoremstyle{change}
\theorembodyfont{\itshape}
\theoremheaderfont{\scshape}
15。怎样在latex中包括一每列的源文件?
答:例如
\floatstyle{boxed}
\restylefloat{figure}
\begin{figure}[hb]
\begin{listing}{1}
#include <stdio.h>
int main(int argc, char **argv)
{
int i;
for (i = 0; i < argc; ++i)
printf("argv[%d] = %s\n", i, argv[i]);
return 0;
}
\end{listing}
\caption{A numbered C program}
\end{figure}
16。怎样把附录A中的公式序号变为 A.1, A.2, .... B.1, B.2, ...的形式?

答: \appendix
\makeatletter
\renewcommand\theequation{A.\@arabic\c@equation }
\makeatother
\setcounter{equation}{0}
或者 \renewcommand{\theequation}{A.\arabic{equation}}
17。怎样把一个 \vertatim 放入 verbatim环境中?
答:用fancyvrb宏包定义自己的 verbatim环境。

18。怎样改变主文本中的字体?

答:命令: \textnorml;申明: \normalfont\ttfamiliy
19。怎样定义一个命令或申明 ?

答:例如一个命令: \newcommand{\name}{1]{\textsc{#1}}

一个申明: \newcommand{\name}{1]{{\normalfont\scshape #1}}
20。怎样合并字体命令?

答: \textrm{...} {\rmfamily...} roman familiy
\textsf{...} {\sffamliy...} sans serif family
\texttt{...} {\ttfamily...} typewritter family
\textmd{...} {\mdserier...} medium series
\textbf{...} {\bfseries...} bold series
\textup{...} {\upshape...} upright shape
\textit{...} {\itshape...} italic shape
\textsl{...} {\slshape...} slanted shape
\textsc{...} {\scshape...} small caps shape
size \tiny \scriptsize \footnotesize \small \normalsize \large
\Large \LARGE \huge \Huge
\emph{...} {\em ...} emphasized
\textnormal{...} {\normalfont...} document font
21。 怎样在页眉和页脚中划一道横线?

答:用 fancyhdr宏包。

22。怎样改变章节字体(section fonts)?
答:用titlesec宏包,例如

\usepackage[nops,sf,small,compact]{titlesec}
23。怎样做一个页面设置?

答: \usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{} %clear all fields
\fancyhead[RO, LE]{\bfseries \LaTeXe{} HOWTO}
\fancyfoot[LE, RO]{\thepage\ of \pageref{LastPage}}
\fancyfoot[LO, CE]{}
\fancyfoot[CO, RE]{Techical Report}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
24。怎样实现"page M of N"的形式?
答:用lastpage宏包,任何时候你都可在文本中用 \pageref{LastPage},只是须注意当用了fancyhdr宏包时,lastpage宏包就须在它后面。

25。怎样实现下划线的标题?

答: \def\@evenhead{\makebox[0pt][l]{\rule[-0.15cm]{\textwidth}{0.1mm}}\hbox{}%

\textbf\thepage\hfil\leftmark}%

\def\@oddhead{\makebox[0pt][l]{\rule[-0.15cm]{\textwidth}{0.1mm}}\hbox{}%
{\rightmark}\hfil\textbf\thepage}%
26。 怎样把一个浮动对象固定下来?

答:例如
\begin{figure}[h]
...
\end{figure]
27。怎样定义一个新的浮动 "float" 形式?
答:用float宏包,用\newfloat就可定义新的浮动形式,它的语法是:
\newfloat{type}{placement}{ext}{within}
- type 是浮动新类型名
- placement 可以是 t, b, p, h 和 H
- ext 是以章节列序的任何图表的后缀名
\floatstyle{style}, 其中 style 可以是
- plain, 空白
- boxed, 盒子
- ruled,
\floatname{float}{floatname}
定义了浮动标题名,像图的 "Figure" 等等。

\restylefloat{float}用于改变图表的标准浮动形式,例如可以
\floatstyle{ruled}
\restylefloat{table}
一个例子是:
\documentclass{article}
\usepackage{float, times}
\thispagestyle{empty}
\floatstyle{ruled}
\newfloat{Program}{thp}{lop}[section]
\floatstyle{boxed}
\newfloat{algorithm}{thp}{loa}
\floatname{algorithm}{Algorithm}
\begin{document}
\section{Let's begin}
This document show some possibilities of \texttt{float.sty}
for floating objects.
\begin{Program}
\begin{verbatim}
#include <stdio.h>
int main(int argc, char **argv)
{
int i;
for (i = 0; i < argc; ++i)
printf("argv[%d] = %s\n", i, argv[i]);
return 0;
}
\end{verbatim}
\caption{A simple C program}
\end{Program}
....
\end{document}
28。 怎样让文字在一个窄小的浮动图周围?
答:用floatfig宏包,其改进宏包是floatflt宏包。语法是 \begin{floatingfigure}[options]{width of figure}
figure contents
\end{floatingfigure}
一个例子是:
\documentclass{article}
\usepackage{floatfig, epsfig}
...bla bla bla
\par
\begin{floatingfigure}{6cm}
... anything possible in figure environment
\end{floatingfigure}
后面的文本将会和浮动图形平行 ,可惜floatfig宏包不是Miktex自带的。


也可用 <wrapfigure> 宏包,语法为

\begin{wrapfigure}[nlines]{placement}{width}figure, caption, etc.
\end{wrapfigure}
- nlines定义了文本折行为,每一个方程占3行。
- placement水平位置(l,r)
- width图形宽度
一个例子是
\begin{wrapfigure}{r}{3in}
\begin{boxit}
\begin{center} This is a "wrapfigure" \end{center}
\caption{A wrapfigure example}
\end{boxit}
\end{wrapfigure}
注意, wrapfigure 是不浮动的,所以它可能和浮动图形的顺序就不一样了,并且它不能在“列表list”中,详见王磊的插图指南。

也可用 picins 宏包,命令是

\parpic(width,height)(x-off,y-off)[Options][Position]{Picture}
段落文本
除了 Picture 以外所有的命令都是可选的,详见王磊的插图指南。

29。怎样使图形并列?

答:用subfigure宏包。

一个例子是 \begin{figure}
\centering
\mbox{ \subfigure[Big]{\includegraphics ...} \quad
\subfigure[Small]{\includegraphics ...} \quad
\subfigure[Medium]{\includegraphics ...} \quad }
\caption{Three subfigures}
\label{fig:subfigures}
\end{figure}
30。把一幅 .eps 横向放置后,怎样使标题变为相应的形式?

答: \usepackage{rotating}

\begin{sidewaysfigure}\centering
\includegraphics[width=?cm]{*.eps}
\caption{...}
\end{sidewaysfigure}

 

 

 

Copyright © 2002-2008 ChinaTeX All Rights Reserved
本站由 川大知识在线成都百利科技有限公司提供赞助