CTex的安装与使用

引言:最近听王老师在课上提到了Tex,貌似是一种高端的论文排版工具,于是乎,准备学习一波骚操作,在网上找到了CTex这个软件,用的好像挺多的,所以摸索一下。


目录


CTex的安装

返回目录

从官网上进行下载,传送门
在这里插入图片描述
在这里插入图片描述
下载好以后,运行安装程序进行安装

CTex的使用

返回目录

主要参考这两篇文章:
CTeX使用
(LaTex)CTex的初次使用心得及入门教程

博客中存在的错误或一些其他补充,在下方列出

生成pdf

返回目录

打开安装路径,我的是D:\CTEX\WinEdt
在这里插入图片描述
双击运行
在这里插入图片描述
Ctrl+n新建文件,输入如下代码

\documentclass{ctexart}
\begin{document}
Hello, CTex!
\end{document}

Ctrl+Shift+P运行文件,选择保存路径后,会自动运行,稍等片刻后,会生成pdf的预览,在保存的路径下,也可以找到生成的pdf。
在这里插入图片描述

生成title

返回目录

输入如下代码,运行,便可看到标题

\documentclass{ctexart}
\title{This is the Title}
\begin{document} 
\maketitle % 显示标题的关键语句
Hello, CTex!
\end{document}

在这里插入图片描述

隐藏时间

返回目录

通过\date{}便可隐藏时间

具体代码:

\documentclass{ctexart}
\title{This is title}

\date{}

\begin{document} \maketitle

\end{document}

运行结果:
在这里插入图片描述

section的左对齐

返回目录

Tex中section默认是居中的,需要进行设置
\CTEXsetup[format={\Large\bfseries}]{section}
具体使用:

\documentclass{ctexart}
\CTEXsetup[format={\Large\bfseries}]{section}

\title{This is title} 

\date{}

\begin{document} 

\maketitle

\section{First Class Title}

\subsection{Second Class Title}

\subsubsection{Second Class Title}

\end{document}

在这里插入图片描述
效果实现。

英文摘要

返回目录

参考文献:LaTex(PART VI) 摘要和关键字

我的电脑上,默认是中文的摘要字样,需要自己去设置,具体代码:

\documentclass{ctexart}

\title{英文摘要}

\newcommand{\enabstractname}{Abstract}
\newenvironment{enabstract}{
    \par\small
    \noindent\mbox{}\hfill{\bfseries \enabstractname}\hfill\mbox{}\par
    \vskip 2.5ex}{\par\vskip 2.5ex}

\begin{document}

\maketitle

\begin{enabstract} % 英文摘要
This is abstract.
\end{enabstract}

\end{document} 

效果:
在这里插入图片描述

参考文献

返回目录

参考blog:

第一步

在.tex文件的路径下新建ref.bib文件,用记事本打开。在里面填充一下内容:

@article{zuo_two-hop_2012,
	title = {A two-hop clustered image transmission scheme for maximizing network lifetime in wireless multimedia sensor networks},
	volume = {35},
	issn = {01403664},
	url = {https://linkinghub.elsevier.com/retrieve/pii/S0140366411002362},
	doi = {10.1016/j.comcom.2011.07.009},
	abstract = {In traditional wireless sensor networks, normal sensor nodes which measure scalar physical phenomena like temperature, pressure and humidity usually compress the data before sending them out to minimize the communication energy consumption. However, this strategy may not be suitable for image transmission in wireless multimedia sensor networks. In the traditional clustering structure, when the cameraequipped node or the cluster head compresses the images, an energy hole will appear. This is a key factor that affects the lifetime of the network. To avoid the energy hole problem, a two-hop clustered image transmission scheme is proposed in this paper. In the proposed scheme, many redirectors are used to compress and forward the images for the purpose of reducing energy consumption of the camera-equipped node and the cluster head. With adaptive adjustment of the transmission radius in the camera cluster and tasks allocation based on the residual energy of the normal sensor nodes by the camera-equipped node, the energy consumption of the nodes in the network is balanced. The experimental results show that the proposed scheme can prolong the network lifetime dramatically in the case of the sensor nodes deployed densely.},
	language = {en},
	number = {1},
	urldate = {2019-02-18},
	journal = {Computer Communications},
	author = {Zuo, Zhen and Lu, Qin and Luo, Wusheng},
	month = jan,
	year = {2012},
	pages = {100--108},
	file = {Zuo 等。 - 2012 - A two-hop clustered image transmission scheme for .md:E\:\\Zotero\\storage\\IZHIJGUT\\Zuo 等。 - 2012 - A two-hop clustered image transmission scheme for .md:text/plain;Zuo 等。 - 2012 - A two-hop clustered image transmission scheme for .pdf:E\:\\Zotero\\storage\\5HJN9QQ7\\Zuo 等。 - 2012 - A two-hop clustered image transmission scheme for .pdf:application/pdf;Zuo 等。 - 2012 - A two-hop clustered image transmission scheme for .pptx:E\:\\Zotero\\storage\\F8M2ASKS\\Zuo 等。 - 2012 - A two-hop clustered image transmission scheme for .pptx:application/vnd.openxmlformats-officedocument.presentationml.presentation}
}

这个是文献的BibTeX,大家可以自行百度生成方式,我这里是通过zotero直接导出的。
在这里插入图片描述

第二步

在需要生成引用列表的地方添加如下代码:

\bibliographystyle{unsrt}
\bibliography{ref}

比如这样:

\documentclass{ctexart}

\title{参考文献}

\begin{document}

\maketitle

\bibliographystyle{unsrt}
\bibliography{ref}

\end{document}

代码里的unsrt是可以根据自己的需求进行替换的,unsrt相当于是指明了参考文献的排序顺序。
在这里插入图片描述
Ctrl+Shift+P生成pdf文档,便可看到“参考文献”的字样,如果没有出现,就多运行几次。

如果想让“参考文献”字样变成“Reference”,可使用\renewcommand\refname{Reference}

\renewcommand\refname{Reference}
\bibliographystyle{unsrt}
\bibliography{ref}

这个时候,还没有具体的文献出现,这是因为我们并没有去引用。

第三步

通过\cite{name}去引用文献,其中,name是bib文件中的第一行,比如这个:
在这里插入图片描述
具体代码:

\documentclass{ctexart}

\title{参考文献}

\begin{document}

\maketitle

引用\cite{zuo_two-hop_2012}

\bibliographystyle{unsrt}
\bibliography{ref}

\end{document}

此时,在运行(Ctrl+Shift+P),就会出现引用文献了。
在这里插入图片描述

此时已经大功告成了。
如果需要引用的超链接,可以继续往下看。

第四步

添加hyperref包即可。
具体代码:

\documentclass{ctexart}
% 添加hyperref包
\usepackage[colorlinks,citecolor=black]{hyperref} % black为引用的颜色,可以调成比如red看看效果  

\title{参考文献}

\begin{document}

\maketitle

引用\cite{zuo_two-hop_2012}

\bibliographystyle{unsrt}
\bibliography{ref}

\end{document}

此时“引用”后面的1就可以点了。
在这里插入图片描述

页眉与页脚

返回目录

这一部分目前我没遇到什么问题,可以参考这篇博客 Latex之自定义页眉页脚

自定义编号

返回目录

首先导入包\usepackage{enumerate},然后就可以自定义了。

\begin{enumerate}[1)]
  \item a
  \item b
  \item c
\end{enumerate}

效果:
在这里插入图片描述
大家可以自行修改自定义的格式。

提高查看速度的方法

返回目录

首先,点击PDFTeXify生成pdf。

之后,如果对tex文件做了修改,只需要运行PDFLatex即可,而不同再运行PDFTeXify了。
在这里插入图片描述

实现中文书签和中文参考文献

返回目录

使用Latex去写中文,真的很头疼,各种编码问题,这里总结一下如何实现中文书签,并同时实现中文参考文献。

先上代码。

\documentclass[UTF-8]{article}

\usepackage{CTEX}
\usepackage[colorlinks,
    citecolor=black,
    linkcolor=black,
    anchorcolor=black]{hyperref}
\hypersetup{CJKbookmarks=true}

\begin{document}

\section{标题一}

\subsection{标题二}

\section{标题二}

\newpage

\nocite{*}
\renewcommand\refname{Reference}
\bibliographystyle{unsrt}
\bibliography{ref}

\end{document}

注意一下,tex文件需要设置成ANSI的编码,还有ref.bib文件也要设置成ANSI编码。

对上面的代码说明一下,引入的两个包CTEX是用于支持中文的,hyperref包是用于生成书签的。

将Tex文件写好,然后点击PDFLaTex运行一次,之后在Tex菜单中选择BibTex运行,然后再运行PDFLaTex两次,就可以了。(我用的是WinEdt,如果大家找不到这些按钮的位置,可以给我留言,我截图给大家)

一些报错

! Impropex alphabetic constant.

返回目录

在这里插入图片描述

在导入hyperref包后,\section{}中就不能加中文了,不然会报这个错。此时,只需要加入一行配置就好了。

\usepackage[colorlinks,citecolor=black]{hyperref}
\hypersetup{CJKbookmarks=true}

这样就可以解决了。

分段函数无法换行问题

返回目录

文章里面需要用到分段函数,安装网上的教程这么写,但效果不尽人意。

\begin{equation} \label{equ:energy_consume_send}
E_{tx}(l,d) = 
\begin{cases}
    E_{elec} \cdot l + \varepsilon_{fs} \cdot l \cdot d^2, d < d_0
    \\
    E_{elec} \cdot l + \varepsilon_{mp} \cdot l \cdot d^4, d \ge d_0
\end{cases}
\end{equation}

效果:
在这里插入图片描述
并没有换行。

通过摸索,发现,加入包amsmath就会换行了。使用这个语句导入包\usepackage{amsmath}

使用IEEE模板,图片caption不显示

使用了IEEE模板,理论上是不支持中文的,但是可以通过\usepackage{ctex}使得支持中文,但是运行之后会发现,图片的caption通通不显示了。

经过实践发现,此时再添加\usepackage{caption}就可以使caption显示了。

  • 9
    点赞
  • 64
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值