latex里面latex renewcommandd什么意思

Latex中修改Section编号
一般用到的latex模板中,section,subsection都是自动编号的,要么是罗马字母(Roman or
roman),英文字母(Alph or alph),还有阿拉伯数字(arabic),如果不想让编号,只需要将原有的\section{}
变成\section*{}.
我今天遇到的问题是,原本的latex模板中,所有的section,subsection都不自动编号,而我希望他们能够自动编号,解决办法是设置计数器\setcounter.
For example:
\setcounter{secnumdepth}{3}: %表示section层次深度为3
\renewcommand\thesection{\arabic{section}} %
这个时候,section就会以阿拉伯数字1,2,3编号
\renewcommand\thesection{\Roman{section}}%
大写的罗马字母,I,II,III,IV...
\renewcommand\thesection{\Alph{section}}
%Alph:大写字母,alph小写字母,roman小写罗马字母
\renewcommand\thesubsection{\arabic{subsection}} %
二级标题就会以罗马数字自动编号
同样的,如果想修改公式等等的编号格式,都可以通过\renewcommand来实现,如编号1,2,3,,,改为A1,A2...
\setcounter{equation}{‘数字’}%这里的‘数字’是你想要设成的数字,比如6,7,11等等的,
&然后文中公式的编号就会从‘数字’+1开始,即数字设为6了,文章中第一个公式编号就是7.
\renewcommand\theequation{A\arabic{equation}} �,
注:\setcounter{对象}{数字}设置对象的计数器
&\renewcommand{\command}{\newcommand}重新设置command的呈现形式为\newcommand
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。CUED - Extending LaTeX
IT Services
Extending LaTeX
LaTeX lets you write new commands (or adapt old ones), create or adapt
environments, and write your own packages and even classes.
This document will
give detailed descriptions on how to do simple things, but won't cover
all the issues relating to class creation.
Sometimes you might want to repeat a long expression. The tidy way to do
this is to use \def (or \newcommand). The following defines \xdt to
produce something like X.desktop
\def\xdt{$\cal X\!\!$\texttt{.desktop}}
One problem that can arise is that your new code can introduce unwanted
space. The
section of the FAQ covers this issue.
Use \newcommand to create a command and \renewcommand to
over-write an existing one. You can use only letters in the names of commands.
\newcommand -
A completely new command can be created using
\newcommand{\
commandname}[number of arguments]{
command text, using #1, #2 etc to denote arguments}
For example,
\newcommand{\ve}[1]{\(#1_1 ... #1_n\)}
produces as output
x1 ... xn.
A problem with this example is that it shouldn't change to math mode if
LaTeX is already in that mode. A better try would be
\newcommand{\ve}[1]{\ensuremath{#1_1 ... #1_n}}
which will only change to math mode if it's necessary.
The following weekday macro uses the ifthen
package. Note the use of '%' characters to suppress spaces in the final
output. weekday{3} should print out Wednesday.
\usepackage{ifthen}
\newcommand{\weekday}[1]%
\ifthenelse{\equal{#1}{1}}{Monday}{}%
\ifthenelse{\equal{#1}{2}}{Tuesday}{}%
\ifthenelse{\equal{#1}{3}}{Wednesday}{}%
\ifthenelse{\equal{#1}{4}}{Thursday}{}%
\ifthenelse{\equal{#1}{5}}{Friday}{}%
\ifthenelse{\equal{#1}{6}}{Saturday}{}%
\ifthenelse{\equal{#1}{7}}{Sunday}{}%
\weekday{3}
\renewcommand -
Let's start with some short though useful examples.
Suppose you wanted to have References in a book
rather than Bibliography. If you look in book.cls you'll
\newcommand\bibname{Bibliography}
\renewcommand{\bibname}{References}
to your file should achieve what you want.
Counters (e.g. figure - a variable that stores the figure
number) have related commands
(e.g. thefigure) to control their appearance, so
they're easy to customise
\renewcommand\thefigure{\roman{figure}}
produces figure numbers in lower case roman numerals.
Longer commands can be adapted too. Remember however, that if the
command involves a @ character you have to enclose your changes in
\makeatletter ... \makeatother or put the code
into a package. Here's an example that
changes the appearance of section headings, making them into centred
small caps
\makeatletter
\renewcommand{\section}{\@startsection{section}{1}{0mm}
{\baselineskip}%
{\baselineskip}{\normalfont\normalsize\scshape\centering}}%
\makeatother
\begin{document}
The following's adapted from the
Rather than overwriting an old command it's common to want to add some
code at the beginning or the end of it.
Suppose we want a version of a command that does some
small extension of its original definition: we might try:
\renewcommand{\splat}{addedcode\splat}
However, this would not work: a call to \splat would execute
addedcode, and then call the redefined \splat this is an infinite recursive loop.
Fortunately, the TeX primitive \let command it allows us to take a "snapshot" of the current state of a command, which we can then
use in the redefinition of the command. So:
\let\Oldsplat\splat
\renewcommand{\splat}{addedcode\Oldsplat}
effects the required patch, safely. Adding things at the end of a command
works similarly.
If \splat takes arguments, one must pass them on:
\renewcommand{\splat}[2]{addedcode\Oldsplat{#1}{#2}}
A new environment is slightly more difficult to create, because you
can define what you want to happen on entering and leaving
the environment.
\newenvironment{\
environmentname}[number of arguments][
default value of the 1st (optional) argument]{
entry code, using #1, #2 etc to denote arguments}
exit code - arguments can't be used}
Simple use isn't as painful as it looks - the following provides a
variant of the itemize command, emphasising the items.
\newenvironment{emlist}{\begin{itemize} \em}{\end{itemize}}
\begin{emlist}
\item first comment
\item second comment
\end{emlist}
The end of the environment ends the scope of the emphasis.
first comment
second comment
The end of the environment ends the scope of the emphasis.
\renewenvironment is used to change existing environments, but
you can't change the number of arguments an environment takes.
A package needn't have any special code, but usually it starts with
some special package commands
\NeedsTeXFormat{LaTeX2e}[]
means that the package requires a version of LaTeX2e dating no further
back than .
\ProvidesPackage{amsmath}[ v2.13 AMS math features]
defines the package name (in this case amsmath) and a string to be printed out when the package is used.
\RequirePackage{amssymb,mathptm}
tries to load in any prerequisite packages if they haven't been loaded in already
\DeclareOption{intlimits}{\let\ilimits@\displaylimits}
creates and defines an option for the package
\DeclareOption{nonamelimits}{\PassOptionsToPackage{nonamelimits}{amsopn}}
creates an option, in this case passing the option onto another
package (but you have to load the package later)
\ExecuteOptions{nointlimits,sumlimits,namelimits,centertags}
executes some default options
\ProcessOptions
- processes the code of each option that was both specified and declared
When writing a package you should try to minimize name-clashes
Prefix each variable and command name by the package name
Use @ in the name of internal variables so that users
can't access them directly
Useful utilities from builting packages include
Creating a class file needs more work than package creation does.
A class file can use
many of the commands mentioned in the Packages section. In addition
it can use
\ProvidesClass{handout}
to define its name.
\LoadClass[12pt,twoside,openright]{book}
to load in an existing class (one wouldn't normally write a class file from scratch).
A complete set of the
documented source of LaTeX may be prepared by processing the
produces the standard classes other than letter,
and may itself be formatted with LaTeX
(see the "Macro programming" section).
for more details.latex 之参考文献的写法---------Bibtex
实现参考文献的全自动化, o(&_&)o 本文需要有一定的LaTeX基础&BibTeX是比较专业的整理参考文献的方法,而且方便在tex文件中引用,但是里面有很多小细节需要注意。&用 LaTeX 处理文档, 经常就要书写参考文献,& 这里介绍 LaTeX 默认的 thebibliography 环境,如果要了解 LaTeX 中更高级的参考文献管理工具 BibTeX, 请见这里BibTeX使用介绍.另外一种经常用的小技巧是, 把文档中的 Reference 写成中文的&参考文献&如果文档类是article之类的, 用\renewcommand\refname{参考文献}如果文档类是book之类的, 用\renewcommand\bibname{参考文献}
本文需要有一定的LaTeX基础在编写latex文件时,参考文献是个比较头疼的问题,以前自己写的时候总是用\begin{thebibliography}\bibitem author,article, year, vol,\end{thebibliography}
我要说这个方法太业余,现在要带你鸟枪换炮! Oh,yeah!这里要用的就是BibTeX,它可以把你编写好的参考文献文件自动插入tex文件中,形成专业的参考文献格式!那就开始吧,首先需要了解一下几个基本概念,也就是几种文件类型:tex---就是tex文件,这个地球人都知道bib---参考文献所在的文件bst---参考文献样式文件这里插一句,有时候注意下英文缩写很重要,容易发现问题,bst=bibliography style下来开始编辑这三个文件,一般情况下bst由系统提供,所以不需要编写,不过当你发表期刊的时候,期刊一般会提供样式文件给你,毕竟各个期刊对参考文献的要求就不一样,国内还没有看到这样的期刊,和国际接轨还需时日。
\documentclass[a4paper, 11pt]{article}%===================Package Area==================%\usepackage[top=1.5cm, bottom=2cm, left=1cm, right=1cm]{geometry}\usepackage{CJK}\usepackage{indentfirst}\usepackage{textcomp}\usepackage{latexsym}\usepackage{amssymb}\usepackage{amsmath}\usepackage[dvips]{graphicx}\usepackage{flafter}\usepackage{booktabs, longtable}\usepackage{caption2}\usepackage{pxfonts}\usepackage{cite}\usepackage{enumerate}%===============End Package Area==================%\begin{document}\begin{CJK*}{GBK}{song}\CJKindent%------------中文设置--------------------------\makeatletter %将文献引用作为上标出现,增加括号,\def\@cite#1#2{\textsuperscript{[{#1\if@tempswa , #2\fi}]}}\makeatother\renewcommand{\refname}{\centerline{参考文献}}\renewcommand{\tablename}{表}\renewco
分享这篇日志的人也喜欢
中午好宝宝们
你好可爱哟
终于空下来了直播来了!
被屏蔽的新人
热门日志推荐
人人最热标签
北京千橡网景科技发展有限公司:
文网文[号··京公网安备号·甲测资字
文化部监督电子邮箱:wlwh@··
文明办网文明上网举报电话: 举报邮箱:&&&&&&&&&&&&
请输入手机号,完成注册
请输入验证码
密码必须由6-20个字符组成
下载人人客户端
品评校花校草,体验校园广场

我要回帖

更多关于 latex中newcommand 的文章

 

随机推荐