Saturday, September 23, 2017

TeX: 中文多字体使用通用示范

一直以来,LaTeX应用中文就各处不适,其中之一就是不方便调整中文字体。终于,我在网上找到一个有营养的帖子,似乎可以对这一问题迎刃而解了。
已知本地已安装CTeX,而CTeX包含MikTeX 2.9,MikTeX又包含XeTeX,所以XeTeX已经在本地安装。编译之时xetex代替tex、xelatex代替latex命令即可。下面就是一个简单的例子,将下面的代码以UTF-8编码方式保存成一个文本文件,命名为test.tex
1
2
3
4
%如何了解本地安装的中文字体?在CMD运行如下命令:
fc-list :lang=zh-cn %简体中文
fc-list :lang=zh-tw %繁体中文
fc-list :lang=ja %日文
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
\documentclass[12pt,a4paper]{article}
\usepackage{fontspec}
\usepackage{hyperref}
 
\setmainfont{SimSun}
\begin{document}
   % \tableofcontents
    \newpage
    \section{宋体}
        测试简体字
    \section{简体中文}
    \fontspec{Microsoft YaHei}中国北京 \\
       \fontspec{FZYaoTi} 中国北京  \\
       \fontspec{NSimSun} 中国北京 \\
       \fontspec{STXinwei} 中国北京 \\
       \fontspec{STHupo} 中国北京 \\
       \fontspec{STXingkai} 中国北京 \\
        \fontspec{STLiti} 中国北京 \\
        \fontspec{STZhongsong} 中国北京 \\
        \fontspec{LiSu} 中国北京 \\
            \section{繁体中文}
         \fontspec{PMingLiU} 中國北京 \\
          \fontspec{MingLiU} 中國北京 \\
          \fontspec{Microsoft JhengHei} 中國北京 \\
          \fontspec{HanWangWCL10} 中國北京
               \section{日文}
               \fontspec{Meiryo UI} 北京中国 \\
               \fontspec{MS Mincho} 北京中国 \\
                \fontspec{IPAexMincho} 北京中国 \\
\end{document}
对于Beamer,
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
\documentclass{beamer}
\usepackage{pgfpages}
%\setbeameroption{show notes}
%\setbeameroption{show notes on second screen=right}
\mode<presentation> {
  \usetheme{Warsaw}
  % ou autre ...

  \setbeamercovered{transparent}
  % ou autre chose (il est également possible de supprimer cette ligne)
}


\usepackage[french]{babel}
\usepackage[latin1]{inputenc}
%\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{tikz}
%\pgfdeclareimage[height=0.5cm]{le-logo}{logo-irisa}
%\logo{\pgfuseimage{le-logo}}
\setbeamertemplate{footline}[frame number]


%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{multicol}
\usepackage{fontspec}
\setmainfont{SimSun}
\AtBeginSection[]
{
\begin{frame}<beamer>{Table of Contents}
\begin{multicols}{2}
\tableofcontents[currentsection,currentsubsection, 
    hideothersubsections, 
    sectionstyle=show/shaded,
]
 \end{multicols}
\end{frame}
}

%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title[Patterns for SoS Reconfiguration] 
{{\fontspec{Microsoft YaHei}中国}Approach Based Patterns for System-of-Systems Reconfiguration}
%\subtitle {ne compléter que si l'article possède un sous-titre}

\author[Franck, Petitdemange] 
{F.~Petitdemange\inst{1} \and I.~Borne\inst{1} \and J.~Buisson\inst{2}}

\institute[]
{
  \inst{1}%
  IRISA\\
  University of South Brittany\\
  Vannes, France
  \and
  \inst{2}%
  IRISA\\
  Military Academy of St-Cyr\\
  Vannes, France}

\date[SESOS 2015] 
{Software Engineering for Systems-of-Systems, 2015}



\begin{document}
\begin{frame}

  \titlepage

\end{frame}

\begin{frame}{Plan}
  %\tableofcontents
  \begin{multicols}{2}
  \tableofcontents[hideallsubsections]
    \end{multicols}
\end{frame}

\section{\fontspec{Microsoft YaHei}中国}
%\frame{\tableofcontents[currentsection]}
\subsection{SoS Engineering Process}
\begin{frame}{SoS Engineering Process}
  {\fontspec{SimSun} 中国北京}
  \fontspec{SimSun} 中国北京
  %\includegraphics[scale=0.3, angle=-90]{construction-process}
%  \input{figures/fig_engineering-process}
\end{frame}

\subsection{SoSADL}
\begin{frame}{Architecture desciption language : SoSADL}
\begin{description}
  \item[{\fontspec{SimSun} 中国北京}Constituent System (CS) :] have their own managerial and
    operational independance while contributing to the global mission
    of the SoS
  \item[Mediator :] controled by the SoS. They belong to the
    SoS. Mediateur are communicating element that specify, coordinate
    the interaction beetween CSs and SoS control over them.
  \item[Coalition :] a set of contraints about the CSs and
    mediator required to accomplish a emergent behavior.
\end{description}
\end{frame}

\subsection{Context}
\begin{frame}{Emergency service SoS}
\begin{description}
  \item[Mission :] preserve human life and material
\end{description}
%\input{figures/fig_emergency-service-exemple}
\end{frame}

\section{Patterns for SoS reconfiguration}
\subsection{Motivation}
\begin{frame}{Need of architectural reconfiguration} 
  Cause :
  \begin{itemize}
  \item managerial and operational independance of the constituents
  \end{itemize}
  Consequence :
  \begin{itemize}
  \item architecture evolve continuesly
  \end{itemize}
  Problems :
  \begin{itemize}
  \item determine a set of reconfiguration' operations to maintain architectural pattern in the concrete architecture?
  \item determine a set of reconfiguration' operations to make evolve the architectural pattern in a coherently way?   
  \end{itemize}
\end{frame}

\begin{frame}{Architectural pattern}
%  \includegraphics[angle=-90, scale=0.5]{pattern-emergency-service}
\end{frame}

\begin{frame}{Maintain architectural patterns}
%\includegraphics[angle=-90, scale=0.4]{cas-maintain-pattern}
\end{frame}

\begin{frame}{Architectural pattern evolutions}
%\includegraphics[angle=-90,scale=0.4]{cas-evolution-pattern}

In this slide, some important text will be
\alert{highlighted} beause it's important.
Please, don't abuse it.
 
\begin{block}{Remark}
Sample text
\end{block}
 
\begin{alertblock}{Important theorem}
Sample text in red box
\end{alertblock}
 
\begin{examples}
Sample text in green box. "Examples" is fixed as block title.
\end{examples}


\end{frame}

\subsection{Approach}
\begin{frame}{Patterns for reconfiguration}
  Approach :
  \begin{itemize}
  \item use pattern approach to formalize a set of best practice to assist
    reconfiguration
  \end{itemize}

  \begin{itemize}
  \item based on dedicaded language (SoSADL), describe SoS architecture
    pattern architectural taking into account SoS characteristics
  \item express a set of reconfiguration operations associate to this
    architectural pattern which can express for instance :when, how,
    for which to add a new CS.
  \end{itemize}
\end{frame}


\begin{frame}{Challenges}
  \begin{itemize}
  \item the choice of reconfiguration' operations in order to instanciate or reinstanciate the architectural pattern
  %\item ... 
  \end{itemize}
\end{frame}

\section{Related Works}

\begin{frame}{}
\end{frame}

\section{Conclusion}

\begin{frame}{Challenge and Futur Work}
  Challenge : 
  \begin{itemize}
  \item
  \end{itemize}

  Futur Work :
  \begin{itemize}
  \item
  \end{itemize}
\end{frame}

\section{Conclusion}

\begin{frame}{Challenge and Futur Work}
  Challenge : 
  \begin{itemize}
  \item
  \end{itemize}

  Futur Work :
  \begin{itemize}
  \item
  \end{itemize}
\end{frame}

\section{Conclusion}

\begin{frame}{Challenge and Futur Work}
  Challenge : 
  \begin{itemize}
  \item
  \end{itemize}

  Futur Work :
  \begin{itemize}
  \item
  \end{itemize}
\end{frame}

\section{Conclusion}

\begin{frame}{Challenge and Futur Work}
  Challenge : 
  \begin{itemize}
  \item
  \end{itemize}

  Futur Work :
  \begin{itemize}
  \item
  \end{itemize}
\end{frame}

\end{document}
beamer尺寸之16:9,
1
\documentclass[aspectratio=169]{beamer}

References

Friday, September 22, 2017

CMD控制台中文乱码的解决方法

默认情况下,Windows的CMD控制台常常不支持中文显示,看上去是一些乱码,这就很不方便了。
Fig. 1
解决之道是修改CMD的文件编码类型,新建一个名为cmd.reg的文件,内容如下:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
Windows Registry Editor Version 5.00




[HKEY_CURRENT_USER\Console\%SystemRoot%_system32_cmd.exe]

"CodePage"=dword:0000fde9

"FontFamily"=dword:00000036

"FontWeight"=dword:00000190

"FaceName"="Consolas"

"ScreenBufferSize"=dword:232900d2

"WindowSize"=dword:002b00d2
新建之后,双击该文件运行。重新启动CMD,此时它支持中文如Fig.2。
Fig. 2

Reference

Monday, September 18, 2017

Data: CHIRPS Global Gridded Rainfall V2.0

Introduction

Climate Hazards Group InfraRed Precipitation with Station data (CHIRPS) is a 30+ year quasi-global rainfall dataset. Spanning 50°S-50°N (and all longitudes), starting in 1981 to near-present, CHIRPS incorporates 0.05° resolution satellite imagery with in-situ station data to create gridded rainfall time series for trend analysis and seasonal drought monitoring. As of February 12th, 2015, version 2.0 of CHIRPS is complete and available to the public, and in NetCDF, GeoTiff, Bil format. The value of -9999 is used for bad values.

NetCDF

Download Ftp Address: ftp://ftp.chg.ucsb.edu/pub/org/chg/products/CHIRPS-2.0/global_monthly/netcdf/.
The NC data file should be converted to GeoTiff format to further investigation. However, this file is so LARGE, the memory of computer must be 30GB at least. Then, this file is not recommended to download to application.
Fig. 1

GeoTiff (Highly Recommended)

Download Ftp Address: ftp://chg-ftpout.geog.ucsb.edu/pub/org/chg/products/CHIRPS-2.0/global_monthly/tifs/
The number of GTiff files is 436, consisting of 198101~201707, and everyone can download them using ftp software (e.g. Fillzilla).
1
2
3
4
ftp chg-ftpout.geog.ucsb.edu
username: anonymous 
password: your_email_address
cd  /pub/org/chg/products/CHIRPS-2.0/
Fig. 2

References

[2] CHIRPS FAQ.
[3] Funk, C.C., Peterson, P.J., Landsfeld, M.F., Pedreros, D.H., Verdin, J.P., Rowland, J.D., Romero, B.E., Husak, G.J., Michaelsen, J.C., and Verdin, A.P., 2014, A quasi-global precipitation time series for drought monitoring: U.S. Geological Survey Data Series 832, 4 p., http://dx.doi.org/110.3133/ds832.

Wednesday, September 6, 2017

京东集团在线笔试试题练习(算法工程师)

小东和三个朋友一起在楼上抛小球,他们站在楼房的不同层,假设小东站的楼层距离地面N米,球从他手里自由落下,每次落地后反跳回上次下落高度的一半,并以此类推知道全部落到地面不跳,求4个小球一共经过了多少米?(数字都为整数)
给定四个整数A,B,C,D,请返回所求结果。
测试样例:
100,90,80,70
返回:1020
我的M代码:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
clear;
clc;

% Height Array
heArr=[100, 90, 80, 70];
sumway=[];
for ii=1:length(heArr)
    orig_height=heArr(ii);
    total_way=0;
    a=orig_height;
    while(a>0)
        total_way=total_way+round(a+a/2);
        a=a/2;
    end
    
    sumway=[sumway, total_way];
    
end

result=sum(sumway);