<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="http://blog.shawpan.cn/atom.xml" rel="self" type="application/atom+xml" /><link href="http://blog.shawpan.cn/" rel="alternate" type="text/html" /><updated>2026-06-01T16:53:10+00:00</updated><id>http://blog.shawpan.cn/atom.xml</id><title type="html">Shawpan’s Blog</title><subtitle>My Blog</subtitle><author><name>Shaw Pan</name></author><entry xml:lang="zh"><title type="html">重启人生计划——3</title><link href="http://blog.shawpan.cn/life/2026/06/01/restart_life_plan_3/" rel="alternate" type="text/html" title="重启人生计划——3" /><published>2026-06-01T00:00:00+00:00</published><updated>2026-06-01T00:00:00+00:00</updated><id>http://blog.shawpan.cn/life/2026/06/01/restart_life_plan_3</id><content type="html" xml:base="http://blog.shawpan.cn/life/2026/06/01/restart_life_plan_3/"><![CDATA[<p>拥抱AI，拥抱生活。</p>

<!--more-->

<p>AI的变化实在太快，agent还没出来之前，我还觉得AI只是一个增强的搜索工具，对于编程或是写自动化脚本这些还比较弱。虽然能生成一段代码，但是代码的可执行性、环境依赖，都需要人去操作验证，而人在这个方面是最大的短板。所以，之前一直以为AI在编程方面，还有很长的路要走。</p>

<p>这段时间，试用了公司的agent后，颠覆了我对AI的认识。agent替代了部分人的操作，比如安装环境依赖，对生成代码的校验及修改，加了agent这个中间层，人就可以用自然语言来编程、处理事情，或者说，人只要能把需求提清楚，agent就能实现，效率得到了极大提升。</p>

<p>之前需要人来编程的事，现在就得到了极大的简化。</p>

<p>再说下拥抱生活。</p>

<p>上个月部门的变动挺大的。部长换了，老技术专家走了，连仅存的一个徒弟也走了。</p>

<p>徒弟临走前进行了一次促膝长谈。对她的离开表示理解和祝福，同时，对自己的不足，也有了更深刻地认识。以前总是想的多，畏手畏脚，陷入内耗中。其实没有必要，与其去猜，不如马上行动去试错，然后反思总结，下次做的更好。人与人之间的关系，亦是如此。想清楚，多些坦诚相待。能交到知己，是人生一大幸事；交不到，那就是缘分末到，淡然看待，随心就好。</p>

<p>主动、勇敢、真诚、乐观，永远是拥抱生活的态度。世界是个巨大的草台班子，但在每个细微之处，都能感受到人情冷暖。</p>

<blockquote>
  <p>Written with <a href="https://stackedit.io/">StackEdit</a>.
<!--stackedit_data:
eyJoaXN0b3J5IjpbLTUyNjk3MDc1MCwxMzM2MzM0ODUwLC02OT
AzOTc3MjddfQ==
--></p>
</blockquote>]]></content><author><name>Shaw Pan</name></author><category term="life" /><category term="life" /><category term="plan" /><summary type="html"><![CDATA[拥抱AI，拥抱生活。]]></summary></entry><entry xml:lang="zh"><title type="html">重启人生计划——2</title><link href="http://blog.shawpan.cn/life/2026/02/05/restart_life_plan_2/" rel="alternate" type="text/html" title="重启人生计划——2" /><published>2026-02-05T00:00:00+00:00</published><updated>2026-02-05T00:00:00+00:00</updated><id>http://blog.shawpan.cn/life/2026/02/05/restart_life_plan_2</id><content type="html" xml:base="http://blog.shawpan.cn/life/2026/02/05/restart_life_plan_2/"><![CDATA[<p>拥抱变化，终身学习。</p>

<!--more-->

<p>上次说到了软件上的工具，这次说一下硬件上的工具。</p>

<p>终于还是买了个matepad，手机还是小了点，用pad屏更大，同步也买了个手写笔，体验了一下手写笔记的感觉。</p>

<p>不得不说，菊厂的手写笔体验还不错。</p>

<p>希望能通过先进的生产工具来提升生产效率。</p>

<p>后面多产出些，按照目前一年屈指可数的几篇，还是太慢了。</p>

<blockquote>
  <p>Written with <a href="https://stackedit.io/">StackEdit</a>.
<!--stackedit_data:
eyJoaXN0b3J5IjpbLTQzMTczNDcxNSwtOTEzMzY2MzQ1LDE0NT
M0MDc0NzldfQ==
--></p>
</blockquote>]]></content><author><name>Shaw Pan</name></author><category term="life" /><category term="life" /><category term="plan" /><summary type="html"><![CDATA[拥抱变化，终身学习。]]></summary></entry><entry xml:lang="zh"><title type="html">重启人生计划——1</title><link href="http://blog.shawpan.cn/life/2025/11/22/restart_life_plan_1/" rel="alternate" type="text/html" title="重启人生计划——1" /><published>2025-11-22T00:00:00+00:00</published><updated>2025-11-22T00:00:00+00:00</updated><id>http://blog.shawpan.cn/life/2025/11/22/restart_life_plan_1</id><content type="html" xml:base="http://blog.shawpan.cn/life/2025/11/22/restart_life_plan_1/"><![CDATA[<p>君欲善其事，必先利其器。</p>

<!--more-->

<p>如之前找到stackedit+github写博客，极大减小了处理博客格式和上传的成本，依托在线处理，不用每次都要花半天时间配置环境。</p>

<p>同样，一些生产力软件，我也希望能够轻装上阵。也就是说，随时随地能够干起活来。如此，一些在线的生产力软件，便是我的所求。</p>

<ul>
  <li><strong>CAD画图</strong>：元宝问了一下，在线免费的，还可以导出stp格式的，<a href="https://www.onshape.com/en/">onshape</a>软件是个不错的选择。onshape的画图逻辑跟creo差不多，刚好去年自学过一段时间Creo，上手起来会容易一些。查了一下onshape的创始人，确实和Creo有一段渊源。哈哈，有意思。需要注意的是，onshape是海外的软件，所以使用的时候最好有代理。</li>
  <li><strong>原理图和PCB</strong>：之前听说过<a href="https://lceda.cn/">嘉立创</a>，单没用过，嘉立创每个月有免费打板的福利，后面可以多尝试一下。原理图和PCB已经有10年没碰过了，该捡起来的是时候捡起来了。</li>
  <li><strong>电路模拟</strong>：同事推荐了一个开源的软件<a href="https://www.falstad.com/circuit/circuitjs.html">circuitjs</a>，网上查了一下，还有在线的版本，挺好的。</li>
</ul>

<blockquote>
  <p>Written with <a href="https://stackedit.io/">StackEdit</a>.
<!--stackedit_data:
eyJoaXN0b3J5IjpbLTU1MzE4NDQ1NCwxMTg0MTc0MzYyLC01NT
MxODQ0NTQsMTc2MDYzNjE2MCwtMTE4NzA2Mzg4M119
--></p>
</blockquote>]]></content><author><name>Shaw Pan</name></author><category term="life" /><category term="life" /><category term="plan" /><summary type="html"><![CDATA[君欲善其事，必先利其器。]]></summary></entry><entry xml:lang="zh"><title type="html">重启人生计划——0</title><link href="http://blog.shawpan.cn/life/2025/11/16/restart_life_plan_0/" rel="alternate" type="text/html" title="重启人生计划——0" /><published>2025-11-16T00:00:00+00:00</published><updated>2025-11-16T00:00:00+00:00</updated><id>http://blog.shawpan.cn/life/2025/11/16/restart_life_plan_0</id><content type="html" xml:base="http://blog.shawpan.cn/life/2025/11/16/restart_life_plan_0/"><![CDATA[<p>蜉蝣一日，草木一秋，人生一世。</p>

<!--more-->

<p>又一年过去了，去年到今年，最大的一个事，就是生了个娃。宝宝降临到这个家庭，自然是非常惊喜，但也增加了许多压力。既然决定要生下来，那就得尽可能的给他一个好的环境。为此，也买了新房，换了个相对舒适的环境。最近看到一句话，大致说是：有些情感太重，过早地压在懵懂的年少，总担心会压坏些什么。或许是那份年轻气少、那份天真无邪、那份初生牛犊不怕虎的勇气。比起成才，更希望他能成人，做一个乐观积极向上的人，对生活百折不挠，不忘初心。</p>

<p>几个契机，重启了这个博客，并开始了我的人生重启计划。</p>

<p>1、给娃做个榜样，发现娃的模仿能力很强。虽然他现在还不会说，但我们说的一些东西，做的一些事，他能懂，会模仿。虽然他现在对妈妈比较依赖，但不希望他觉得爸爸是个可有可无的人。希望他能尽早地发现他的爱好，在未来漫长的道路上能抵抗艰难险阻；培养动手能力，能快速把想法变成现实。而这些，如果我只是跟他说说，可能就变成了说教了，只有自己言行身教，他才能更深的理解体会。</p>

<p>2、最近跟部门的前同事吃了顿饭，同事分享了下他的经历，也问了个很尖锐的问题，或者是我一直困扰的问题，就是你的目标是什么？知道了目标，才有方向，才能心无旁骛的去朝着这个目标前进。比如走专家路线，那就一门心思搞技术，能在这个领域做到公司最强。这个问题，从读博第一天，就困扰着我。如果一门心思搞技术，那就应该留在高校，研究这个领域最前沿、最新的技术；但如今的高校，也如升级打怪，或许若干年后，能混到比较好的社会地位，但可能还是会为了钱到处奔波；那先解决了钱的问题，如何？之前给自己定了一个目标：40岁之前，在工业界赚够了钱，40岁后，再回学术界好好搞研究。只是这赚够钱，谈何容易。经济形势下行，公司的打怪升级之路也非易事，一个萝卜一个坑。是时候再好好审视一下目标了。</p>

<p>3、刚过了35，是时候该考虑人生的下半场了。其实从小时候，喜欢看个人传记胜过看小说或者散文，特别是那些创业家的故事。骨子里面，还是希望自己能做成一件事，创办一家自己的公司。不求达到上市，只求以后能衣食无忧。以后再做选择时，能不被钱左右。其实就是大家说的财务自由。以前在十三线小城市，觉得一千万就能实现财务自由；现在在一线城市，发现这个想法就像富了以后一顿要吃十个馒头一样可笑。是时候给自己定下一个小目标了。</p>

<blockquote>
  <p>Written with <a href="https://stackedit.io/">StackEdit</a>.
<!--stackedit_data:
eyJoaXN0b3J5IjpbOTg5MjQ4MTkxLDEyNDk1NzE0OTQsLTE5NT
c1NDM1MzcsMTA5NjI5OTk1MywtOTgyNDUyNzQwLDY5MDU5ODgz
MywtMTU4NjUwNzg4OF19
--></p>
</blockquote>]]></content><author><name>Shaw Pan</name></author><category term="life" /><category term="life" /><category term="plan" /><summary type="html"><![CDATA[蜉蝣一日，草木一秋，人生一世。]]></summary></entry><entry xml:lang="zh"><title type="html">解决开机启动时不识别USB蓝牙的问题</title><link href="http://blog.shawpan.cn/others/2024/09/19/fix_bluetooth_bug/" rel="alternate" type="text/html" title="解决开机启动时不识别USB蓝牙的问题" /><published>2024-09-19T00:00:00+00:00</published><updated>2024-09-19T00:00:00+00:00</updated><id>http://blog.shawpan.cn/others/2024/09/19/fix_bluetooth_bug</id><content type="html" xml:base="http://blog.shawpan.cn/others/2024/09/19/fix_bluetooth_bug/"><![CDATA[<p>最近使用蓝牙键盘，但是电脑一重启，键盘就打不了字了，排查了一下，是开机时不识别USB蓝牙的问题。
<!--more-->
在<a href="https://zhuanlan.zhihu.com/p/450759260">知乎</a>上找到了解决方案，由于遇到过几次，所以还是记录一下吧。</p>

<p>Windows 11台式机下使用USB蓝牙适配器，可能会在每次启动时插拔一次蓝牙适配器才可以正常使用。</p>

<p>解决方法为：</p>

<ol>
  <li>运行services.msc。</li>
  <li>找到“蓝牙支持服务”和“蓝牙音频网关服务”。</li>
  <li>将这两个服务的启动类型设置为“自动（延迟）”。</li>
</ol>

<p>完后重启一下就好了。</p>

<blockquote>
  <p>Written with <a href="https://stackedit.io/">StackEdit</a>.
<!--stackedit_data:
eyJoaXN0b3J5IjpbMTU3NDMzNjczNV19
--></p>
</blockquote>]]></content><author><name>Shaw Pan</name></author><category term="others" /><category term="win10" /><category term="bugs" /><summary type="html"><![CDATA[最近使用蓝牙键盘，但是电脑一重启，键盘就打不了字了，排查了一下，是开机时不识别USB蓝牙的问题。 在知乎上找到了解决方案，由于遇到过几次，所以还是记录一下吧。]]></summary></entry><entry xml:lang="zh"><title type="html">使用stackeditor.io在线编辑github博客</title><link href="http://blog.shawpan.cn/js/2024/05/19/use_stackeditor_to_write_blog.md/" rel="alternate" type="text/html" title="使用stackeditor.io在线编辑github博客" /><published>2024-05-19T00:00:00+00:00</published><updated>2024-05-19T00:00:00+00:00</updated><id>http://blog.shawpan.cn/js/2024/05/19/use_stackeditor_to_write_blog.md</id><content type="html" xml:base="http://blog.shawpan.cn/js/2024/05/19/use_stackeditor_to_write_blog.md/"><![CDATA[<p>最近一直在找一个不依赖系统、不依赖电脑的博客编辑方案，找到了这个网站。还不错，只是不支持github图床。
<!--more--></p>

<h3 id="磨刀不误砍柴工">磨刀不误砍柴工</h3>

<p>俗话说，磨刀不误砍柴工。博客中断了6年，之前编辑博客的电脑也坏了，环境都没了，一些配置，一些用法，都不记得了，现在都需要重新拾起来。考虑到未来也可能会出现同样的状况，有些环境也会随日新月异的变化而过时，所以想用一个跟本地环境能解耦的方案，同时可以随时随地的登录编辑。</p>

<p>最直接的方法，就是直接编辑github上面的文件，还好之前用的是jekyll框架，markdown按照模板格式写完后，就能自动编译了，也不需要手动输入命令（之前一直担心需要自己编译，还看了一段时间github action实现自动化 :&lt;）。</p>

<p>直接在github编辑markdown的最大缺陷在于不直观，没法实时渲染。所以找一个曲线救国的方法：找一款在线markdown编辑器，要么能在线存储文档，或者能及时同时能同步到github上，这样就能摆脱主机的限制、系统的限制。</p>

<h3 id="金斧头还是银斧头">金斧头还是银斧头</h3>

<p>在线markdown编辑器，有几种形式：
1、自带后台，提供账户存储，比如一些笔记软件（为知笔记、石墨等），这种在线编辑markdown确实比较方便，但同步到github上，就需要比较麻烦的操作了；另外，总感觉如果只是写博客，用这些笔记类的软件，有点大材小用。
2、不带后台，数据直接存储在浏览器storage中，比如<a href="https://stackedit.io/app#">StackEdit</a>、<a href="https://github.com/doocs/md">doocs.md</a>、<a href="https://pandao.github.io/editor.md/en.html">Editor.md</a>，其中StackEdit可以直接同步github的文章，doocs.md能很方便地排版成微信公众号文章，Editor.md是个功能强大的编辑器，可以嵌入公式、流程图、还可以写PPT，甚至它本身也可以嵌入网页中，作为一个嵌入式的markdown编辑器。
由于博客主要挂在github上，所以个人偏向于用StackEditor，但StackEdit有个问题，没法添加图床，后面等插图用的多了再说吧，可能需要再找一个解决插图的工具吧。
3、基于github的开源在线markdown编辑器，自己二次开发一套适配的markdown编辑器，但考虑到这是个不小的工程，还是先不考虑了。</p>

<h3 id="先动手吧">先动手吧</h3>
<p>在《精力管理》里面有句话：</p>
<blockquote>
  <p>人们总是高估一天能完成的事，而低估30天能完成的事。</p>
</blockquote>

<p>先动手写起来吧。</p>

<blockquote>
  <p>Written with <a href="https://stackedit.io/">StackEdit</a>.</p>
</blockquote>

<!--stackedit_data:
eyJwcm9wZXJ0aWVzIjoidGl0bGU6IOS9v+eUqHN0YWNrZWRpdG
9yLmlv5Zyo57q/57yW6L6RZ2l0aHVi5Y2a5a6iXG5hdXRob3I6
IHNoYXdwYW5cbnRhZ3M6ICdyZXNvdXJjZXMsamVreWxsJ1xuY2
F0ZWdvcmllczogSlNcbmRhdGU6ICcyMDI0LTA1LTE5J1xuZXh0
ZW5zaW9uczpcbiAgcHJlc2V0OiBnZm1cbiIsImhpc3RvcnkiOl
syMDk5OTY4NjExLDE4MDQ2NjY0NzYsLTQ2NjgzMzk5LDEyOTU2
MTg4NDEsLTY3NjQwNTQxNiw4NTAyMzU1MywyMTI3MzA0NjI1LD
E4MDM4NTc4NzBdfQ==
-->]]></content><author><name>Shaw Pan</name></author><category term="JS" /><category term="resources" /><category term="jekyll" /><summary type="html"><![CDATA[最近一直在找一个不依赖系统、不依赖电脑的博客编辑方案，找到了这个网站。还不错，只是不支持github图床。]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://gastonsanchez.com/images/blog/mathjax_logo.png" /><media:content medium="image" url="http://gastonsanchez.com/images/blog/mathjax_logo.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry xml:lang="zh"><title type="html">test blog is OK or not</title><link href="http://blog.shawpan.cn/js/2024/04/06/test_blog_is_ok_or_not/" rel="alternate" type="text/html" title="test blog is OK or not" /><published>2024-04-06T00:00:00+00:00</published><updated>2024-04-06T00:00:00+00:00</updated><id>http://blog.shawpan.cn/js/2024/04/06/test_blog_is_ok_or_not</id><content type="html" xml:base="http://blog.shawpan.cn/js/2024/04/06/test_blog_is_ok_or_not/"><![CDATA[<p>6年没有写博客了，看看这套框架怎么用
<!--more--></p>

<p><img class="centered" src="https://www.mathjax.org/badge/mj-logo.svg" /></p>

<h3 id="正常吗">正常吗？</h3>

<p>能显示就是正常吧</p>]]></content><author><name>Shaw Pan</name></author><category term="JS" /><category term="resources" /><category term="jekyll" /><summary type="html"><![CDATA[6年没有写博客了，看看这套框架怎么用]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://gastonsanchez.com/images/blog/mathjax_logo.png" /><media:content medium="image" url="http://gastonsanchez.com/images/blog/mathjax_logo.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry xml:lang="zh"><title type="html">iecas_thesis FAQ（一）——子图中的括号</title><link href="http://blog.shawpan.cn/latex/2019/04/15/iecas_thesis_FAQ/" rel="alternate" type="text/html" title="iecas_thesis FAQ（一）——子图中的括号" /><published>2019-04-15T00:00:00+00:00</published><updated>2019-04-15T00:00:00+00:00</updated><id>http://blog.shawpan.cn/latex/2019/04/15/iecas_thesis_FAQ</id><content type="html" xml:base="http://blog.shawpan.cn/latex/2019/04/15/iecas_thesis_FAQ/"><![CDATA[<p>使用模板时遇到了引用图像子图不带括号的问题。</p>

<!--more-->

<h3 id="问题描述">问题描述</h3>

<p>在写论文时，会遇到一处图片有多个子图的情况。对于子图，可以使用subfigure宏包来处理，然后可以向添加图片一样添加子图。如果要引用子图，则需要在子图中添加标签，然后使用\ref{}来引用该标签。</p>

<p>如下图中，有4个子图，对于子图(a)，添加标签\label{fig:oaspl_a}，在正文引用时，使用\ref{fig:oaspl_a}。</p>

<p><img src="https://github.com/MELCHIOR-1/melchior-1.github.io/raw/master/images/FAQ_subfig_1.png" alt="" /></p>

<p>上图红框标出了问题所在：在引用单张图时，我们希望时”图 XX”，而在引用子图时，希望时”图 XX(a)”，为什么？因为上图中的子图标题就带有括号，这样引用显得一一对应。</p>

<h3 id="解决方法">解决方法</h3>

<p><strong>step 1.</strong></p>

<p>为了解决这个问题，首先想到的就是改写thesubfigure命令。尝试在Thesis.tex的导言区中添加如下命令：</p>

<div class="language-latex highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">\renewcommand</span><span class="p">{</span><span class="k">\thesubfigure</span><span class="p">}{</span>(<span class="k">\alph</span><span class="p">{</span>subfigure<span class="p">}</span>)<span class="p">}</span>
</code></pre></div></div>

<p>得到的效果是这样的：</p>

<p><img src="https://github.com/MELCHIOR-1/melchior-1.github.io/raw/master/images/FAQ_subfig_2.png" alt="" /></p>

<p>可以看到，虽然引用子图标号外面现在有括号了，但是大图中子图的标号也会多一层。</p>

<p>**step 2. **</p>

<p>查阅资料后发现在Thesis.tex的导言区中添加命令：</p>

<div class="language-latex highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">\usepackage</span><span class="na">[labelformat=simple]</span><span class="p">{</span>subcaption<span class="p">}</span>
</code></pre></div></div>

<p>即在加载subcaption宏包时添加[labelformat=simple]配置选项，就可以解决这个问题。编译结果如下：</p>

<p><img src="https://github.com/MELCHIOR-1/melchior-1.github.io/raw/master/images/FAQ_subfig_3.png" alt="" /></p>]]></content><author><name>Shaw Pan</name></author><category term="LaTeX" /><category term="sty" /><category term="latex" /><summary type="html"><![CDATA[使用模板时遇到了引用图像子图不带括号的问题。]]></summary></entry><entry xml:lang="zh"><title type="html">自己动手写LaTeX模版系列（四）——那些年你多写的图表</title><link href="http://blog.shawpan.cn/latex/2019/04/14/DIY_1_cleveref/" rel="alternate" type="text/html" title="自己动手写LaTeX模版系列（四）——那些年你多写的图表" /><published>2019-04-14T00:00:00+00:00</published><updated>2019-04-14T00:00:00+00:00</updated><id>http://blog.shawpan.cn/latex/2019/04/14/DIY_1_cleveref</id><content type="html" xml:base="http://blog.shawpan.cn/latex/2019/04/14/DIY_1_cleveref/"><![CDATA[<p>种一棵树最好的时间是十年前，其次是现在。只要你心里有信念，没有时间的差距，什么时候开始都可以。——Dambisa Moyo</p>

<!--more-->

<p>LaTeX一个迷人的优点就是引用非常智能，不会出现“错误！未找到引用源”（Word的老梗）。</p>

<p>虽然解决了引用关联的问题，但是仍有2处让人感觉比较繁琐。</p>

<p>1、每次引用的时候，需要写“图~\ref{}”或“表~\ref{}”。写小论文还要好点，顶多多写几十个“图~”或“表~” (Figure~ or Table~)；轮到写大论文可就惨了，图、表、公式加起来可能有几百个了吧。</p>

<p>2、在写英文论文时，有的期刊要求使用“Figure”，而有些则使用“Fig.”，表格和公式也是如此；在写中文论文时，也会遇到“式(1)”和“(1)式”的纠结。</p>

<h3 id="是痛点吗">是痛点吗？</h3>

<p>在工作中，逐渐学会了在做一件事情前先进行价值和难度的评估。即做这件事情的价值大吗（不做会死吗，做成了会带来多大的收益）？做件事的时间和人力成本有多大？</p>

<p>但经常这样思考，会容易让人陷入一个短视和功利的状态。有些事情，在短期看来，费时又没有带来多大的收益，但如果把眼光放长，会发现这些事情正在潜移默化地改变着我们，长期收益要远大于短期收益。</p>

<p>用LaTeX写作就是一个长期收益要远大于短期收益的事情。大论文不用LaTeX写可以吗？完全可以的，用word一样可以丝溜润滑；那用LaTeX写价值大吗？有人会说LaTeX排版功能很强大，改格式很方便，但是君不知为了搞清楚怎么改格式可能会花费跟在word中傻瓜式重复修改更多的时间。再说了，万一格式要求今年没有变化呢？大论文一气呵成写完了呢？</p>

<p>道理上要做一劳永逸的事情，但一劳永逸的事情是否都值得我们去做？相信大家心里面都有一杆秤。公园的门票，年票比单次票可能就贵一点，你会去买年票吗？</p>

<h3 id="不痛还做吗">不痛还做吗？</h3>

<p>在LaTeX中，有多种宏包可以帮咋们做这件事，如：cleveref, varioref, fancyref和hyberref宏包的\autoref命令等。这里面功能最全最新的要数cleveref，在一篇论文里也可以同时使用多个宏包。</p>

<div class="language-latex highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">\usepackage</span><span class="p">{</span>varioref<span class="p">}</span>
<span class="k">\usepackage</span><span class="p">{</span>hyperref<span class="p">}</span>
<span class="k">\usepackage</span><span class="p">{</span>cleveref<span class="p">}</span>
</code></pre></div></div>

<p>这里注意的是：hyberref需要在cleveref宏包前加载。</p>

<p>接下来，主要讲一下cleveref宏包的用法。</p>

<h3 id="怎么引用">怎么引用？</h3>

<p>不管你是图片引用，还是公式引用，只需要使用\cref{}就可以，剩下的就交给程序去识别，进而输出”fig. XX”或”eq.(XX)”。来段代码感受一下。</p>

<div class="language-latex highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">\documentclass</span><span class="na">[11pt]</span><span class="p">{</span>article<span class="p">}</span>
<span class="k">\usepackage</span><span class="p">{</span>cleveref<span class="p">}</span>
<span class="nt">\begin{document}</span> 
<span class="nt">\begin{equation}</span>
	y=a<span class="p">_</span>1x+b<span class="p">_</span>1<span class="k">\label</span><span class="p">{</span>eqn:1<span class="p">}</span>
<span class="nt">\end{equation}</span> 

Cleveref equation reference (<span class="k">\textbackslash</span> cref): <span class="k">\cref</span><span class="p">{</span>eqn:1<span class="p">}</span>.
<span class="nt">\begin{figure}</span>[ht]
	<span class="k">\centering</span>
	<span class="k">\rule</span><span class="p">{</span>0.5<span class="k">\linewidth</span><span class="p">}{</span>0.1<span class="k">\linewidth</span><span class="p">}</span>
	<span class="k">\caption</span><span class="p">{</span>First figure<span class="p">}</span><span class="k">\label</span><span class="p">{</span>fig:1<span class="p">}</span>
<span class="nt">\end{figure}</span>

Cleveref figure reference (<span class="k">\textbackslash</span> cref): <span class="k">\cref</span><span class="p">{</span>fig:1<span class="p">}</span>.
<span class="nt">\end{document}</span>
</code></pre></div></div>

<p>编译一下，如下图所示：</p>

<p><img src="https://github.com/MELCHIOR-1/melchior-1.github.io/raw/master/images/cleveref_first.png" alt="" /></p>

<h3 id="搞定了吗">搞定了吗？</h3>

<p>相信聪明如你，一眼就可以看出这个例子太简单，实际使用中还会遇到很多问题需要解决，比如：</p>

<ul>
  <li>如果引用是在句首，需要首字母大写怎么办？</li>
</ul>

<p>此时，需要使用\Cref{}，该命令出来的引用首字母会大写。</p>

<div class="language-latex highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">\Cref</span><span class="p">{</span>eqn:1<span class="p">}</span> is a normal linear equation.
</code></pre></div></div>

<ul>
  <li>如果所有的引用首字母都需要大写怎么办？</li>
</ul>

<p>此时，在导言区加载cleveref宏包时添加[capitalise]选项。</p>

<div class="language-latex highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">\usepackage</span><span class="na">[capitalise]</span><span class="p">{</span>cleveref<span class="p">}</span>
</code></pre></div></div>

<ul>
  <li>如果要引用多个公式（或图片）怎么办？</li>
</ul>

<p>分两种情况：</p>

<p>1、当引用的公式不连着，可以把公式的label直接按顺序写到\cref{}里面，中间用逗号隔开，不要加空格。</p>

<div class="language-latex highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">\cref</span><span class="p">{</span>eqn:1,eqn:3,eqn:7<span class="p">}</span>
</code></pre></div></div>

<p>2、当引用的公式连着，有个简单的办法，使用\crefrange{first}{last}，first中填第一个公式的label，last中填最后一个公式的label。如需要引用公式1-7：</p>

<div class="language-latex highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">\crefrange</span><span class="p">{</span>eqn:1<span class="p">}{</span>eqn:7<span class="p">}</span>
</code></pre></div></div>

<ul>
  <li>如果公式和图要混合引用怎么办？</li>
</ul>

<p>作为cref的开发者，势必会把这种情况最为检测cleveref宏包智能性如何的一个测试用例，你可以试试如下语句：</p>

<div class="language-latex highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">\cref</span><span class="p">{</span>eqn:1,fig:1<span class="p">}</span>
</code></pre></div></div>

<ul>
  <li>如果引用时需要全称而不是缩写怎么办？</li>
</ul>

<p>此时，需要在导言区加载cleveref宏包时添加[noabbrev]选项。</p>

<div class="language-latex highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">\usepackage</span><span class="na">[noabbrev]</span><span class="p">{</span>cleveref<span class="p">}</span>
</code></pre></div></div>

<ul>
  <li>如果要定制引用标签怎么办？</li>
</ul>

<p>先解释一下这个问题产生的场景。比如我们需要把引用写成这样子——”fig-X”或”fig: X”；来个更实际的，比如在写大论文时，我们使用的都是”图 X”和”式 (X)”，而对于cleveref，目前还不能根据使用的主语言来输出对应引用标签。什么意思？就是你在ctex环境下，输入的全是中文，使用\cref{fig:1}默认输出的还是fig. 1而不是图1。</p>

<p>这时候自定义设置就派上用场了。在导言区添加如下设置：</p>

<div class="language-latex highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">\crefname</span><span class="p">{</span>equation<span class="p">}{</span>equation<span class="p">}{</span>equations<span class="p">}</span>
</code></pre></div></div>

<p>在命令<code class="language-plaintext highlighter-rouge">\crefname{·}{·}{·}</code>中的第一个参数的含义是引用的类型（equation、table、figure、section等），第二个参数包含的单词，当只有一个引用时将会被输出，当有多个引用是第三个参数将会被输出。在中文情况下：第二个参数和第三个参数可以是汉字，如：<code class="language-plaintext highlighter-rouge">\crefname{equation}{式}{式}</code>。</p>

<ul>
  <li>如果想要点一下引用就跳转到引用源的位置怎么办？如点击”图 1”就可以跳转到图片1的位置？</li>
</ul>

<p>这个功能就属于hyperref的范围了，cleveref能够很好的兼容hyperref，只要添加hyperref宏包就可以了，但是注意，一定要在cleveref之前添加hyperref宏包。</p>

<div class="language-latex highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">\usepackage</span><span class="p">{</span>hyperref<span class="p">}</span>
<span class="k">\usepackage</span><span class="p">{</span>cleveref<span class="p">}</span>
</code></pre></div></div>

<h3 id="怎么写到模版里">怎么写到模版里？</h3>

<p>我们在demo_style.sty中添加如下代码：</p>

<div class="language-latex highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">\RequirePackage</span><span class="p">{</span>graphicx<span class="p">}</span>
<span class="k">\RequirePackage</span><span class="na">[colorlinks=true,linkcolor=black]</span><span class="p">{</span>hyperref<span class="p">}</span> 
<span class="k">\RequirePackage</span><span class="p">{</span>cleveref<span class="p">}</span>
<span class="k">\crefname</span><span class="p">{</span>equation<span class="p">}{</span>式<span class="p">}{</span>式<span class="p">}</span>
<span class="k">\crefname</span><span class="p">{</span>table<span class="p">}{</span>表<span class="p">}{</span>表<span class="p">}</span>
<span class="k">\crefname</span><span class="p">{</span>figure<span class="p">}{</span>图<span class="p">}{</span>图<span class="p">}</span>
</code></pre></div></div>

<p>然后，新建一个tex文档<code class="language-plaintext highlighter-rouge">use_cleveref.tex</code>，输入如下代码：</p>

<div class="language-latex highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">\documentclass</span><span class="p">{</span>thesis<span class="p">_</span>demo<span class="p">}</span>
<span class="k">\usepackage</span><span class="p">{</span>demo<span class="p">_</span>style<span class="p">}</span>
<span class="nt">\begin{document}</span>
	如<span class="k">\cref</span><span class="p">{</span>fig:wechat<span class="p">}</span>所示，为cref的引用演示。
	<span class="nt">\begin{figure}</span>[!htbp]
		<span class="k">\centering</span>
		<span class="k">\includegraphics</span><span class="na">[width=7.5cm]</span><span class="p">{</span>wechat.jpg<span class="p">}</span>
		<span class="k">\caption</span><span class="p">{</span>微信图标<span class="p">}</span>
		<span class="k">\label</span><span class="p">{</span>fig:wechat<span class="p">}</span>
	<span class="nt">\end{figure}</span> 
<span class="nt">\end{document}</span>
</code></pre></div></div>

<p>使用xelatex编译一下，可以生成如下结果：</p>

<p><img src="https://github.com/MELCHIOR-1/melchior-1.github.io/raw/master/images/cleveref_second.png" alt="" /></p>

<p>源码地址：</p>

<p><a href="https://github.com/MELCHIOR-1/How\_to\_write\_a\_LaTeX\_thesis\_template/tree/master/chapter\_1/section5">https://github.com/MELCHIOR-1/How_to_write_a_LaTeX_thesis_template/tree/master/chapter_1/section5</a></p>

<p>参考文章：</p>

<p>[1] <a href="https://texblog.org/2013/05/06/cleveref-a-clever-way-to-reference-in-latex/">Cleveref, a clever way to reference in LaTeX</a></p>

<p>[2] <a href="https://blog.csdn.net/jpzhu16/article/details/50687120">使用宏包cleveref实现自动的引用</a></p>

<p>[3] <a href="http://www.ctex.org/documents/packages/bibref/fancyref.pdf">Fancy Cross-referencing</a></p>

<p>[4] <a href="http://ftp.yzu.edu.tw/CTAN/macros/latex/contrib/cleveref/cleveref.pdf">The cleveref package</a></p>]]></content><author><name>Shaw Pan</name></author><category term="LaTeX" /><category term="sty" /><category term="latex" /><summary type="html"><![CDATA[种一棵树最好的时间是十年前，其次是现在。只要你心里有信念，没有时间的差距，什么时候开始都可以。——Dambisa Moyo]]></summary></entry><entry xml:lang="zh"><title type="html">自己动手写LaTeX模版系列（三）——图表双标题</title><link href="http://blog.shawpan.cn/latex/2018/12/18/DIY_1_bicaption/" rel="alternate" type="text/html" title="自己动手写LaTeX模版系列（三）——图表双标题" /><published>2018-12-18T00:00:00+00:00</published><updated>2018-12-18T00:00:00+00:00</updated><id>http://blog.shawpan.cn/latex/2018/12/18/DIY_1_bicaption</id><content type="html" xml:base="http://blog.shawpan.cn/latex/2018/12/18/DIY_1_bicaption/"><![CDATA[<p>“岁月是朵两生花，涉江而过，花开千朵”</p>

<p>转眼间已经到年底了，离之前计划的目标还剩很远。思考了一下，决定改变写作策略。对于大论文写作来说，有些技巧是你在写作之前就需要掌握的，掌握了这些技巧，一是前期写作的时候能够事半功倍，二是后期减小通篇查找修改的成本；还有一些技巧是在你写作前后掌握都可以的，这类技巧主要是减小你修改格式的时间。所以，接下来我会优先讲解第一类技巧。</p>

<!--more-->

<p>上篇文章讲了LaTeX宏包的写法，实际上，大多数情况下我们都是在用各种各样的宏包。相信大家有了会写宏包的功底，各种宏包对于我们来说就不是黑盒子了，用好各种宏包也就不在话下。</p>

<p>IECAS采用UCAS的毕业论文格式要求后，较之前的论文模版有较大的变化，其中一个区别点就是新版使用了<strong>双标题</strong>。</p>

<h3 id="什么是双标题">什么是双标题？</h3>

<p>这里所说的双标题是指在大论文写作中，图表的标题使用两种语言表述，比如IECAS的大论文，需要使用中英文标题，中文标题在上，英文标题在下。另外，在图表目录中，只显示中文标题。</p>

<p>有人会说，这个简单呀，每个Figure环境里面使用2次caption，在第二次使用caption前计数减1，然后在caption里面输英文就可以了呀。这样虽然解决了图表双标题显示的问题，但是图表目录中，又该如何只显示中文标题呢？对于编译系统来说，中英文都是使用的caption环境，本质上是一样的。</p>

<p>当然，把这些问题解决了，就可以自己编写一个双标题宏包了。根据懒人的思维，有没有人为我们做好了衣服，我们直接穿就行呢？</p>

<p>答案是肯定的，这个宏包就是bicaption，你的双标题解决方案。</p>

<h3 id="bicaption宏包是什么">bicaption宏包是什么？</h3>

<p>bicaption，从名字中可以看出，它是在caption的基础上实现了双语的功能。实际上，在LaTeX包的归档上，它属于caption宏包的一个子包，或者说是增强包。</p>

<h3 id="怎么用bicaption宏包">怎么用bicaption宏包？</h3>

<p>使用bicaption宏包也非常简单，接着之前的模版demo_style宏包，在里面添加bicaption宏包的引用。</p>

<div class="language-latex highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">\RequirePackage</span><span class="na">[list=off]</span><span class="p">{</span>bicaption<span class="p">}</span> <span class="c">% package for binary captions</span>
<span class="k">\captionsetup</span><span class="na">[figure][bi-second]</span><span class="p">{</span>name=Figure<span class="p">}</span> <span class="c">% the second figure caption name</span>
<span class="k">\captionsetup</span><span class="na">[table][bi-second]</span><span class="p">{</span>name=Table<span class="p">}</span> <span class="c">% the second table caption name</span>
</code></pre></div></div>
<p>第一行代码申明了bicaption包的引用，其中<code class="language-plaintext highlighter-rouge">list=off</code>选项表示在图表目录中不显示第二语言标题。看，使用bicaption宏包，目录显示问题一条指令就能解决，是不是很方便？</p>

<p>这里其实引出了一个问题，使用LaTeX后，你可能都已经忘了图表标题编号的问题，因为LaTeX已经帮你处理好了，那么“图XX”中的“图”，或者“Figure XX”中的“Figure”是怎么处理的呢？</p>

<p>对于只有一种语言的文档，比如中文或英文，编译器可以根据class默认的语言来判断，如使用的是ctexbook类，编译出来默认就是“图XX”，而使用texbook类，默认的就是“Figure XX”。那么，对于两种语言的文档，编译器怎么去识别第二种语言呢？</p>

<p>没错，就是使用之前公众号文章中提到的多语言包————babel，在模版引用babel宏包时申明两种语言，前面一个是第二语言，后面一个是主语言，如：</p>
<div class="language-latex highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">\RequirePackage</span><span class="na">[russian,english]</span><span class="p">{</span>babel<span class="p">}</span>
</code></pre></div></div>
<p>第一语言申明是英语，第二语言是俄文。</p>

<p>那么，对于中英文标题（第一语言是中文，第二语言是英文），是不是使用<code class="language-plaintext highlighter-rouge">RequirePackage[english,pinyin]{babel}</code>就行了呢？</p>

<p>这样想就too young, too simple了，对于中文环境的完美适配，LaTeX还有一段路要走。引用刘海洋老师在《LaTeX入门》中提到的：</p>

<blockquote>
  <p>bicaption原本使用babel或polyglossia提供的语言选择机制来设置不同的语言标题，不过中文等东亚语言不使用上述宏包的翻译机制，就需要手工设置不同的语言标题。</p>
</blockquote>

<p>好了，现在问题变成了如何去设置第二语言标题？</p>

<p>上面代码的第二、三行便是对第二语言标题的设置，通过<code class="language-plaintext highlighter-rouge">\captionsetup[figure][bi-second]{name=Figure}</code>将英文图片标题设置为“Figure XX”。</p>

<p>如果你非常好奇，不设置会变成怎么样？亲测了一下，你的中英文标题都显示的是“图XX”。</p>

<p>环境准备好了，可以上手用了。在正文中，在本该使用caption的位置，替换成如下代码：</p>
<div class="language-latex highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">\bicaption</span><span class="p">{</span>中文标题<span class="p">}{</span>english title<span class="p">}</span>
</code></pre></div></div>

<h3 id="炒个栗子">炒个栗子</h3>

<p>按照惯例，举个例子。</p>

<p>先在demo_style.sty中添加对bicaption的设置。</p>
<div class="language-latex highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">\RequirePackage</span><span class="na">[list=off]</span><span class="p">{</span>bicaption<span class="p">}</span><span class="c">% package for binary captions</span>
<span class="k">\captionsetup</span><span class="na">[figure][bi-second]</span><span class="p">{</span>name=Figure<span class="p">}</span><span class="c">% the second figure caption name</span>
<span class="k">\captionsetup</span><span class="na">[table][bi-second]</span><span class="p">{</span>name=Table<span class="p">}</span><span class="c">% the second table caption name</span>
</code></pre></div></div>

<p>新建一个tex文件use_bicaption.tex，写入如下内容：</p>
<div class="language-latex highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">\documentclass</span><span class="p">{</span>thesis<span class="p">_</span>demo<span class="p">}</span>
<span class="k">\usepackage</span><span class="p">{</span>demo<span class="p">_</span>style<span class="p">}</span>
<span class="k">\usepackage</span><span class="p">{</span>graphicx<span class="p">}</span>

<span class="nt">\begin{document}</span>
	<span class="k">\listoffigures</span>
	<span class="k">\newpage</span>
	
	如图~<span class="k">\ref</span><span class="p">{</span>fig:wechat<span class="p">}</span>所示，为bicaption的标题演示。
	<span class="nt">\begin{figure}</span>[!htbp]
		<span class="k">\centering</span>
		<span class="k">\includegraphics</span><span class="na">[width=7.5cm]</span><span class="p">{</span>wechat.jpg<span class="p">}</span>
		<span class="k">\bicaption</span><span class="p">{</span>微信图标<span class="p">}{</span>wechat icon<span class="p">}</span>
		<span class="k">\label</span><span class="p">{</span>fig:wechat<span class="p">}</span>
	<span class="nt">\end{figure}</span> 
<span class="nt">\end{document}</span>
</code></pre></div></div>
<p>使用XeLaTeX编译后，可以得到如下效果：</p>

<p>【目录的效果】</p>

<p><img src="https://github.com/MELCHIOR-1/melchior-1.github.io/raw/master/images/figure_index.png" alt="" /></p>

<p>【标题的效果】
<img src="https://github.com/MELCHIOR-1/melchior-1.github.io/raw/master/images/bicaption_content.png" alt="" /></p>

<p>源码地址：</p>

<p><a href="https://github.com/MELCHIOR-1/How_to_write_a_LaTeX_thesis_template/tree/master/chapter_1/section4">https://github.com/MELCHIOR-1/How_to_write_a_LaTeX_thesis_template/tree/master/chapter_1/section4</a></p>]]></content><author><name>Shaw Pan</name></author><category term="LaTeX" /><category term="sty" /><category term="latex" /><summary type="html"><![CDATA[“岁月是朵两生花，涉江而过，花开千朵”]]></summary></entry></feed>