使用 Markdown 的科学论文中表格的 CSS

问题描述 投票:0回答:1

我正在尝试使用 CSS 在 Rmarkdown 中设置表格的样式,但我找不到一种方法使其看起来像这些科学出版物指南:https://www.springer.com/gp/authors-editors/authorandreviewertutorials/writing -期刊手稿/图表/10285530

我尝试使用在网上找到的 CSS,但它看起来与指南中的 CSS 完全不一样:

/* General table styling */
table {
  border-collapse: collapse;
  width: 100%;
  font-family: Arial, sans-serif;
  font-size: 12px;
}

/* Table header */
th, td {
  border: 1px solid #000;
  padding: 8px;
}

/* No border for the first column */
td:first-child,
th:first-child {
  border-left: none;
}

/* No border for the last column */
td:last-child,
th:last-child {
  border-right: none;
}

/* No border for the first row */
tr:first-child {
  border-top: none;
}

/* No border for the last row */
tr:last-child {
  border-bottom: none;
}

html css r-markdown markdown
1个回答
0
投票

要将 Rmarkdown 中的表格样式设置为类似于 Springer 提供的科学出版物指南,您可以调整 CSS 以包含指南中概述的特定格式元素。下面是一个更新的 CSS 代码片段,它与所需的样式更加一致:

/* General table styling */
table {
  border-collapse: collapse;
  width: 100%;
  font-family: Arial, sans-serif;
  font-size: 12px;
}

/* Table header */
th {
  border: 1px solid #000;
  background-color: #f2f2f2; /* Light gray background for headers */
  padding: 8px;
}

/* Table data */
td {
  border: 1px solid #000;
  padding: 8px;
}

/* No border for the first column */
td:first-child,
th:first-child {
  border-left: none;
}

/* No border for the last column */
td:last-child,
th:last-child {
  border-right: none;
}

/* No border for the first row */
tr:first-child {
  border-top: none;
}

/* No border for the last row */
tr:last-child {
  border-bottom: none;
}

此 CSS 包含表标题的浅灰色背景,这是科学出版物中的常见约定。还进行了调整以保持单元格边框和间距一致。您可以将此 CSS 包含在 Rmarkdown 文档中,以相应地设置表格样式。可以根据具体要求或偏好进一步调整。

© www.soinside.com 2019 - 2024. All rights reserved.