You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Quarto列表中统一处理合著者展示,简化单篇.qmd配置?

可行,实现步骤如下

1. 重构单篇出版物的YAML元数据

将每篇代表出版物的.qmd文件元数据拆分为独立字段,不再把合著者嵌入title,示例如下:

---
title: "基于Quarto的学术出版物列表搭建实践"
co-authors: ["张三", "李四", "王五"]
year: 2024
journal: "开源学术工具期刊"
pdf-url: "./assets/papers/quarto-pub-list.pdf"
journal-url: "https://example-journal.org/issues/2024-01"
---

如果需要给作者添加个人链接,可将co-authors设为对象数组:

co-authors:
  - name: "张三"
    url: "https://zhangsan.example.com"
  - name: "李四"
    url: "https://lisi.example.com"

2. 在index.qmd中配置自定义Listing模板

通过Quarto的listing配置,指定出版物目录、自定义字段,并编写统一展示模板,实现内容与展示逻辑分离。

方式一:自定义卡片式展示

适合灵活排版,在index.qmd的YAML中添加:

---
title: "我的学术出版物"
listing:
  contents: ./papers/  # 替换为你的出版物.qmd所在目录
  fields: [title, co-authors, year, journal, pdf-url, journal-url]
  template: |
    <div class="pub-item">
      <h3>{{ title }}</h3>
      <p>
        <strong>作者:</strong> 
        {{#each co-authors}}
          {{#if url}}<a href="{{url}}">{{name}}</a>{{else}}{{name}}{{/if}}
          {{#unless @last}}, {{/unless}}
        {{/each}}
      </p>
      <p><strong>年份:</strong> {{year}} | <strong>期刊:</strong> <a href="{{journal-url}}">{{journal}}</a></p>
      <p><a class="pdf-link" href="{{pdf-url}}">📥 下载PDF</a></p>
    </div>
---

可配合自定义CSS美化卡片样式(可选):

.pub-item {
  border: 1px solid #eee;
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 4px;
}
.pdf-link {
  color: #2c3e50;
  text-decoration: none;
}
.pdf-link:hover {
  text-decoration: underline;
}

方式二:表格形式展示

如果保留表格布局,可在index.qmd中用Quarto表格结合Listing数据(以R内核为例):

---
title: "我的学术出版物"
listing:
  contents: ./papers/
  fields: [title, co-authors, year, journal, pdf-url, journal-url]
  output: false  # 禁用默认Listing输出,用自定义表格替代
---

```{r}
#| echo: false
#| warning: false
library(dplyr)
library(knitr)

# 获取Listing数据
pubs <- quarto::quarto_listing_metadata("./papers/") %>%
  mutate(
    authors = sapply(co_authors, function(x) {
      if (is.list(x)) {
        paste0("<a href='", sapply(x, "[[", "url"), "'>", sapply(x, "[[", "name"), "</a>", collapse = ", ")
      } else {
        paste(x, collapse = ", ")
      }
    }),
    journal = paste0("<a href='", journal_url, "'>", journal, "</a>"),
    pdf = paste0("<a href='", pdf_url, "'>下载</a>")
  ) %>%
  select(标题 = title, 作者 = authors, 年份 = year, 期刊 = journal, PDF = pdf)

kable(pubs, escape = FALSE, align = "lccc")
## 3. 测试渲染
运行`quarto render index.qmd`,检查出版物列表是否正确读取所有自定义字段并按模板展示。

内容的提问来源于stack exchange,提问作者xounamoun
相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.02 07:57:28