Repository navigation
Expand file tree
/
Copy pathtex_insert_code.html
More file actions
516 lines (399 loc) · 18.4 KB
/
Copy pathtex_insert_code.html
File metadata and controls
516 lines (399 loc) · 18.4 KB
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>tex插入程序代码--so easy~</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->
<link rel="stylesheet" href="./theme/css/bootstrap.css" type="text/css" />
<style type="text/css">
body {
padding-top: 60px;
padding-bottom: 40px;
}
.sidebar-nav {
padding: 9px 0;
}
.tag-0 {
font-size: 20pt;
}
.tag-1 {
font-size: 16pt;
}
.tag-2 {
font-size: 12pt;
}
.tag-4 {
font-size: 8pt;
}
</style>
<link href="./theme/css/bootstrap-responsive.css" rel="stylesheet">
<link href="./theme/css/font-awesome.css" rel="stylesheet">
<link href="./theme/css/pygments.css" rel="stylesheet">
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- Le fav and touch icons -->
<link rel="shortcut icon" href="./theme/images/favicon.ico">
<link rel="apple-touch-icon" href="./theme/images/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="72x72" href="./theme/images/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="114x114" href="./theme/images/apple-touch-icon-114x114.png">
<link href="./feeds/all.atom.xml" type="application/atom+xml" rel="alternate" title="mx's Blog ATOM Feed" />
<link href="./feeds/all.rss.xml" type="application/atom+xml" rel="alternate" title="mx's Blog RSS Feed" />
</head>
<body>
<!-- Baidu Button BEGIN -->
<script type="text/javascript" id="bdshare_js" data="type=slide&img=6&pos=right" ></script>
<script type="text/javascript" id="bdshell_js"></script>
<script type="text/javascript">
var bds_config = {"bdTop":289};
document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + new Date().getHours();
</script>
<!-- Baidu Button END -->
<!-- UJian Button BEGIN -->
<script type="text/javascript" src="http://v1.ujian.cc/code/ujian.js?type=slide"></script>
<!-- UJian Button END -->
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="./index.html">mx's Blog </a>
<div class="nav-collapse">
<ul class="nav">
<li class="divider-vertical"></li>
<li >
<a href="./category/misc.html">
<i class="icon-folder-open icon-large"></i>misc
</a>
</li>
<li >
<a href="./category/music.html">
<i class="icon-folder-open icon-large"></i>music
</a>
</li>
<li >
<a href="./category/soft.html">
<i class="icon-folder-open icon-large"></i>soft
</a>
</li>
<li class="active">
<a href="./category/tech.html">
<i class="icon-folder-open icon-large"></i>tech
</a>
</li>
<ul class="nav pull-right">
<li><a href="./archives.html"><i class="icon-th-list"></i>Archives</a></li>
</ul>
</ul>
<!--<p class="navbar-text pull-right">Logged in as <a href="#">username</a></p>-->
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="span9" id="content">
<section id="content">
<article>
<header>
<h1>
<a href=""
rel="bookmark"
title="Permalink to tex插入程序代码--so easy~">
tex插入程序代码--so easy~
</a>
</h1>
</header>
<div class="entry-content">
<div class="well">
<footer class="post-info">
<span class="label">Date</span>
<abbr class="published" title="2012-03-03T00:00:00">
<i class="icon-calendar"></i>六 03 三月 2012
</abbr>
<span class="label">By</span>
<a href="./"><i class="icon-user"></i>mx</a>
<span class="label">Category</span>
<a href="./"><i class="icon-folder-open"></i>tech</a>.
<span class="label">Tags</span>
<a href="./tag/tex.html"><i class="icon-tag"></i>tex</a>
</footer><!-- /.post-info -->
</div>
<p>这个问题... 我本来想用python解决的...</p>
<p>但是显然应该先搜一下吧... 果然, 早就有人解决了(其实是tex的常用命令里就有的), 比如<a href="http://hi.baidu.com/xuelicheng/blog/item/194c844a22d2452a09f7ef8a.html">这里</a>...</p>
<div class="codehilite"><pre><span class="err">\</span><span class="n">usepackage</span><span class="p">{</span><span class="n">listings</span><span class="p">}</span>
<span class="err">\</span><span class="n">lstset</span><span class="p">{</span><span class="n">language</span><span class="o">=</span><span class="n">C</span><span class="o">++</span><span class="p">}</span><span class="o">%</span><span class="err">这条命令可以让</span><span class="n">LaTeX</span><span class="err">排版时将</span><span class="n">C</span><span class="o">++</span><span class="err">键字突出显示</span>
<span class="err">\</span><span class="n">lstset</span><span class="p">{</span><span class="n">breaklines</span><span class="p">}</span><span class="o">%</span><span class="err">这条命令可以让</span><span class="n">LaTeX</span><span class="err">自动将长的代码行换行排版</span>
<span class="err">\</span><span class="n">lstset</span><span class="p">{</span><span class="n">extendedchars</span><span class="o">=</span><span class="nb">false</span><span class="p">}</span><span class="o">%</span><span class="err">这一条命令可以解决代码跨页时,章节标题,页眉等汉字不显示的问题</span>
<span class="err">\</span><span class="n">begin</span><span class="p">{</span><span class="n">lstlisting</span><span class="p">}</span>
<span class="o">%</span><span class="n">paste</span> <span class="n">your</span> <span class="n">C</span><span class="o">++</span> <span class="n">code</span> <span class="n">here</span>
<span class="err">\</span><span class="n">end</span><span class="p">{</span><span class="n">lstlisting</span><span class="p">}</span>
</pre></div>
<p>很简单的... 不过比较长的代码换行显示不是很爽(貌似不换行也不是办法啊)... 另外没有颜色高亮哎...</p>
<p>嗯, 貌似<a href="http://bbs.chinatex.org/forum.php?mod=viewthread&tid=3692">这里</a>的介绍更详细...
还有这个人的<a href="http://aifreedom.com/technology/170">博客</a>...
<a href="http://blog.sina.com.cn/s/blog_5e16f1770100o9ef.html">这篇文章</a>是针对python的高亮...</p>
<p>总结一下, 这样比较好:</p>
<div class="codehilite"><pre><span class="k">\documentclass</span><span class="nb">{</span>article<span class="nb">}</span>
<span class="k">\usepackage</span><span class="nb">{</span>listings<span class="nb">}</span>
<span class="k">\usepackage</span><span class="nb">{</span>xcolor<span class="nb">}</span>
<span class="k">\usepackage</span><span class="nb">{</span>xeCJK<span class="nb">}</span> <span class="c">%必须加xeCJK包</span>
<span class="k">\setCJKmainfont</span><span class="nb">{</span>WenQuanYi Micro Hei<span class="nb">}</span>
<span class="k">\begin</span><span class="nb">{</span>document<span class="nb">}</span>
<span class="k">\lstset</span><span class="nb">{</span>numbers=left,
numberstyle=<span class="k">\tiny</span>,
keywordstyle=<span class="k">\color</span><span class="nb">{</span>blue!70<span class="nb">}</span>, commentstyle=<span class="k">\color</span><span class="nb">{</span>red!50!green!50!blue!50<span class="nb">}</span>,
frame=shadowbox,
rulesepcolor=<span class="k">\color</span><span class="nb">{</span>red!20!green!20!blue!20<span class="nb">}</span>,
breaklines=true,
extendedchars=true
<span class="nb">}</span>
<span class="k">\begin</span><span class="nb">{</span>lstlisting<span class="nb">}</span>[language=<span class="nb">{</span>Python<span class="nb">}</span>]
<span class="c">%这里插入代码~</span>
<span class="k">\end</span><span class="nb">{</span>lstlisting<span class="nb">}</span>
<span class="k">\end</span><span class="nb">{</span>document<span class="nb">}</span>
</pre></div>
<p>附件: 我做的一个简单实例
<a href="static/tex_insert_code/insertcode2.tex">./insertcode2.tex</a> </p>
<p><strong>imported from zim</strong></p>
</div><!-- /.entry-content -->
<div class="comments">
<h2>Comments !</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
var disqus_identifier = "tex_insert_code.html";
(function() {
var dsq = document.createElement('script');
dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://xweisblog.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] ||
document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
</div>
</article>
</section>
</div><!--/span-->
<div class="span3 well sidebar-nav" id="sidebar">
<ul class="nav nav-list">
<li class="nav-header"><h4><i class="icon-external-link"></i>blogroll</h4></li>
<li><a href="http://log.dofine.me/"><i class="icon-external-link"></i>dofine</a></li>
<li><a href="http://farseerfc.github.com/"><i class="icon-external-link"></i>farseerfc</a></li>
<li><a href="http://hyhx2008.github.com/"><i class="icon-external-link"></i>H.Y.</a></li>
<li class="nav-header"><h4><i class="icon-home icon-large"></i> social</h4></li>
<li><a href="./feeds/all.atom.xml" rel="alternate"><i class="icon-bookmark icon-large"></i>atom feed</a></li>
<li><a href="./feeds/all.rss.xml" rel="alternate"><i class="icon-bookmark icon-large"></i>rss feed</a></li>
<li><a href="https://github.com/x-wei"><i class="icon-github-sign icon-large"></i>github</a></li>
<li class="nav-header"><h4><i class="icon-folder-close icon-large"></i>Categories</h4></li>
<li>
<a href="./category/misc.html">
<i class="icon-folder-open icon-large"></i>misc
</a>
</li>
<li>
<a href="./category/music.html">
<i class="icon-folder-open icon-large"></i>music
</a>
</li>
<li>
<a href="./category/soft.html">
<i class="icon-folder-open icon-large"></i>soft
</a>
</li>
<li>
<a href="./category/tech.html">
<i class="icon-folder-open icon-large"></i>tech
</a>
</li>
<li class="nav-header"><h4><i class="icon-tags icon-large"></i>Tags</h4></li>
<span class="tag-2">
<a href="./tag/快捷键.html">快捷键</a>
</span>
<!-- <i class="icon-tag icon-large"></i> -->
<span class="tag-4">
<a href="./tag/android.html">android</a>
</span>
<!-- <i class="icon-tag icon-large"></i> -->
<span class="tag-2">
<a href="./tag/tips.html">tips</a>
</span>
<!-- <i class="icon-tag icon-large"></i> -->
<span class="tag-1">
<a href="./tag/git.html">git</a>
</span>
<!-- <i class="icon-tag icon-large"></i> -->
<span class="tag-4">
<a href="./tag/Toefl.html">Toefl</a>
</span>
<!-- <i class="icon-tag icon-large"></i> -->
<span class="tag-2">
<a href="./tag/python.html">python</a>
</span>
<!-- <i class="icon-tag icon-large"></i> -->
<span class="tag-1">
<a href="./tag/shell.html">shell</a>
</span>
<!-- <i class="icon-tag icon-large"></i> -->
<span class="tag-2">
<a href="./tag/host.html">host</a>
</span>
<!-- <i class="icon-tag icon-large"></i> -->
<span class="tag-0">
<a href="./tag/google.html">google</a>
</span>
<!-- <i class="icon-tag icon-large"></i> -->
<span class="tag-1">
<a href="./tag/外观.html">外观</a>
</span>
<!-- <i class="icon-tag icon-large"></i> -->
<span class="tag-4">
<a href="./tag/GRE.html">GRE</a>
</span>
<!-- <i class="icon-tag icon-large"></i> -->
<span class="tag-4">
<a href="./tag/linux.html">linux</a>
</span>
<!-- <i class="icon-tag icon-large"></i> -->
<span class="tag-2">
<a href="./tag/出国.html">出国</a>
</span>
<!-- <i class="icon-tag icon-large"></i> -->
<span class="tag-4">
<a href="./tag/巴黎高科.html">巴黎高科</a>
</span>
<!-- <i class="icon-tag icon-large"></i> -->
<span class="tag-4">
<a href="./tag/fr.html">fr</a>
</span>
<!-- <i class="icon-tag icon-large"></i> -->
<span class="tag-4">
<a href="./tag/ubuntu.html">ubuntu</a>
</span>
<!-- <i class="icon-tag icon-large"></i> -->
<span class="tag-2">
<a href="./tag/french.html">french</a>
</span>
<!-- <i class="icon-tag icon-large"></i> -->
<span class="tag-2">
<a href="./tag/tex.html">tex</a>
</span>
<!-- <i class="icon-tag icon-large"></i> -->
<span class="tag-2">
<a href="./tag/中文乱码.html">中文乱码</a>
</span>
<!-- <i class="icon-tag icon-large"></i> -->
<span class="tag-1">
<a href="./tag/pelican.html">pelican</a>
</span>
<!-- <i class="icon-tag icon-large"></i> -->
<span class="tag-4">
<a href="./tag/Simon&Garfunkel.html">Simon&Garfunkel</a>
</span>
<!-- <i class="icon-tag icon-large"></i> -->
<span class="tag-2">
<a href="./tag/markdown.html">markdown</a>
</span>
<!-- <i class="icon-tag icon-large"></i> -->
<br>
<br>
<li class="nav-header"><h4><i class="icon-search"></i>Google Search</h4></li>
<div id="cse" style="width: 100%;">Loading</div>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load('search', '1');
google.setOnLoadCallback(function() {
var customSearchOptions = {}; var customSearchControl = new google.search.CustomSearchControl(
'010017366155264590731:njcqykcxuly', customSearchOptions);
customSearchControl.setResultSetSize(google.search.Search.SMALL_RESULTSET);
customSearchControl.draw('cse');
}, true);
</script>
<link rel="stylesheet" href="http://www.google.com/cse/style/look/default.css" type="text/css" />
<br>
<Script Language="JavaScript">
var timedate= new Date("June 22,2013");
var now = new ate();
var date = now.getTime() - timedate.getTime();
var time = Math.floor(date / (1000 * 60 * 60 * 24));
if (time >= 0) ;
document.write("<p style='text-align: center'><strong><font style='color:black;font-size:36px;'>"+time +"</font></strong> days<br/><strong>since GRADUATION from<br/> Shanghai Jiao Tong University</strong></p>");
</Script>
<br>
<a href="http://www.ubuntu.com/"><img src="http://www.ubuntu.com/countdown/banner1.png" border="0" width="180" height="150" alt="The next version of Ubuntu is coming soon"></a><br/>
<br>
<a href="http://www.sjtu.edu.cn/"><img src="http://x-wei.github.com/static/ssss.jpg" border="0"alt="上海西南某高校"></a><br/>
<br>
<li class="widget-container widget_text">
<h3 class="widget-title">About me</h3>
<div class="textwidget">
上海西南某高校电院学生, Linux桌面低端用户.<br/>
</div></li>
<br>
<li class="widget-container widget_text">
<h3 class="widget-title">推荐文章</h3>
<div class="textwidget">
<a href="http://x-wei.github.com/PT-summery.html">2011巴黎高科(ParisTech)申请总结</a><br>
<a href="http://x-wei.github.com/GT-summery.html">用尽量少的时间考一个够用的分数--一点Tofel/GRE备考经验</a><br>
<a href="http://x-wei.github.com/google_youku_host_20120706.html">[更新]访问google服务和优酷去广告功能的host列表</a><br>
<a href="http://x-wei.github.com/chrome-background.html">chrome护眼设置--把背景设置为绿豆沙</a><br>
<a href="http://x-wei.github.com/xelatex_zh.html">xelatex--linux下tex中文的完全解决!</a><br>
<a href="http://x-wei.github.com/google_doc_form.html">使用google doc建立在线调查表!~</a><br>
<a href="http://x-wei.github.com/pelican_github_blog.html">用pelican在github上创建自己的博客!</a><br>
</div></li>
</ul>
</div><!--/.well -->
</div><!--/row-->
<hr>
<footer>
<address id="about">
Proudly powered by <a href="http://pelican.notmyidea.org/">Pelican <i class="icon-external-link"></i></a>,
which takes great advantage of <a href="http://python.org">Python <i class="icon-external-link"></i></a>.
</address><!-- /#about -->
<p>The theme is from <a href="http://twitter.github.com/bootstrap/">Bootstrap from Twitter <i class="icon-external-link"></i></a>,
and <a href="http://fortawesome.github.com/Font-Awesome/">Font-Awesome <i class="icon-external-link"></i></a>, thanks!</p>
</footer>
</div><!--/.fluid-container-->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-30756331-1");
pageTracker._trackPageview();
} catch(err) {}</script>
<script type="text/javascript">
var disqus_shortname = 'xweisblog';
(function () {
var s = document.createElement('script'); s.async = true;
s.type = 'text/javascript';
s.src = 'http://' + disqus_shortname + '.disqus.com/count.js';
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
}());
</script>
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="./theme/js/jquery.js"></script>
<script src="./theme/js/bootstrap-transition.js"></script>
<script src="./theme/js/bootstrap-alert.js"></script>
<script src="./theme/js/bootstrap-modal.js"></script>
<script src="./theme/js/bootstrap-dropdown.js"></script>
<script src="./theme/js/bootstrap-scrollspy.js"></script>
<script src="./theme/js/bootstrap-tab.js"></script>
<script src="./theme/js/bootstrap-tooltip.js"></script>
<script src="./theme/js/bootstrap-popover.js"></script>
<script src="./theme/js/bootstrap-button.js"></script>
<script src="./theme/js/bootstrap-collapse.js"></script>
<script src="./theme/js/bootstrap-carousel.js"></script>
<script src="./theme/js/bootstrap-typeahead.js"></script>
<!--<script src="./theme/js/autosidebar.js"></script>-->
</body>
</html>