1. 居中内容
首先去 …/layout/shortcodes 文件夹,新建一个叫"center.html"的文件。如果layout里没有,就自己创建一个。注意:不要去PaperMod的theme里找layout。
然后把这些代码插入进去并保存:
<div style="margin: 0 auto; width: fit-content; min-width: 10%; overflow-x: auto;">
{{ .Inner }}
</div>
在未来调用时,按照下方的例子调用就可以。渲染前的效果如下:
{{% center %}}
| Top | Bottom | Left | Right |
| :---: | :---: | :---: | :---: |
| 54.79% | 53.76% | 53.91% | 52.43% |
{{% /center %}}
{{% center %}}
**Table 1.** Variance Explained by 5 Principal Components
{{% /center %}}
渲染后:
| Top | Bottom | Left | Right |
|---|---|---|---|
| 54.79% | 53.76% | 53.91% | 52.43% |
Table 1. Variance Explained by 5 Principal Components
2. 更改文字对齐逻辑
打个比方,我现在希望去选择填充而非左对齐。具体实现方案如下:
如果希望全局应用,那么,在 …/PaperMod/assets/css/extended/blank.css 里,添加下面的内容后,重启hugo server或再部署一次就可以了。
.post-content p {
text-align: justify;
text-justify: inter-word;
hyphens: auto;
}
text-justify: 单词拉伸设置。
hyphens:断词策略,此处设置为自动。
如果只想应用一次到某个特定的文章,那就在markdown的部分最开头插入这些:
<style>
.post-content p {
text-align: justify;
text-justify: inter-word;
hyphens: auto;
}
</style>
应用例如下:
+++
date = '2025-11-27'
title = 'random title...'
tags = ["111"]
...
+++
<style>
.post-content p {
text-align: justify;
text-justify: inter-word;
hyphens: auto;
}
</style>
正文在这里,只要你上面的东西在正文前加入了,下面的文字就会自动设置好。
其它对齐逻辑也是一个道理。
3. 还没有
有了再写,嘿嘿。