码迷,mamicode.com
首页 > 其他好文 > 详细

LaTeX技巧211:latex如何打印出确切时间

时间:2015-07-10 00:09:22      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:

http://blog.sina.com.cn/s/blog_5e16f1770100grtj.html

 

我们在输入一篇文章或者书的标题的时候,会自动加入当天的日期,但是我们如果想把计算机的时间加入文档,该如何实现呢?
解决方案:
有两个宏包提供了打印输出时间的功能,The datetime package and The scrtime package,他们提供了不同的输入方案,如24小时制,12小时制等等,读者可根据自己的要求来选择。

 

演示代码:
\documentclass{article}
\pagestyle{empty}
\setcounter{page}{6}
\setlength\textwidth{305.0pt}
\usepackage{CJK}
\usepackage{times}
\usepackage{datetime}
\usepackage{scrtime}
\begin{CJK}{GBK}{kai}
\begin{document}

Two packages are available, both providing ranges of ways of printing the date, as well as of the time: this question will concentrate on the time-printing capabilities, and interested users can investigate the documentation for details about dates.

The datetime package defines two time-printing functions: \xxivtime (for 24-hour time), \ampmtime (for 12-hour time) and \oclock (for time-as-words, albeit a slightly eccentric set of words).

The scrtime package (part of the compendious KOMA-Script bundle) takes a package option (12h or 24h) to specify how times are to be printed. The command \thistime then prints the time appropriately (though there’s no am or pm in 12h mode). The \thistime command also takes an optional argument, the character to separate the hours and minutes: the default is of course :.

\Large
当前计算机的时间和日期是:


\xxivtime \, \today

\ampmtime\, \today

\oclock\, \today

\thistime\, \today

\end{CJK}
\end{document}

摘自:http://www.tex.ac.uk/cgi-bin/texfaq2html?label=time

LaTeX技巧211:latex如何打印出确切时间

标签:

原文地址:http://www.cnblogs.com/daijkstra/p/4634425.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!