为Rmarkdown的YAML标题中的数字设置标题字体大小

时间:2016-05-10 11:06:43

标签: r yaml rstudio knitr r-markdown

我正在使用Rstudios markdown编写一份报告,我希望使用latex以及html编译为pdf ...

在某种程度上可以调整usInputSubnet = input("How many subnets does your network have?: ") inputSubnet = int(usInputSubnet) dunamh = 1 while inputSubnet > (2 ** dunamh) - 2: dunamh += 1 usInputMaxHost = input("How many Max Host does your network have?: ") inputMaxHost = int(usInputMaxHost) dunamh1 = 1 while inputMaxHost > (2 ** dunamh1) - 2: dunamh1 += 1 sunoloDunamewn = dunamh + dunamh1 dunamhSubnet = dunamh count = 0 while dunamhSubnet >= 8: dunamhSubnet -= 8 count += 1 if sunoloDunamewn >= 25: Class = 'Non exist' elif sunoloDunamewn >= 17: Class = 'A Class' elif sunoloDunamewn >= 9: Class = 'B Class' elif sunoloDunamewn >= 1: Class = 'C Class' else: Class = "GTP" if dunamhSubnet == 1: id = 128 elif dunamhSubnet == 2: id = 64 elif dunamhSubnet == 3: id = 32 elif dunamhSubnet == 4: id = 16 elif dunamhSubnet == 5: id = 8 elif dunamhSubnet == 6: id = 4 elif dunamhSubnet == 7: id = 2 elif dunamhSubnet == 8: id = 1 bytes = [0, 128, 192, 224, 240, 248, 252, 254, 255] idVar = id idVarStr = str(idVar) if Class == "A Class": if count == 0: firstByte = str(255) secondByte = str(bytes[dunamhSubnet]) thirdByte = str(0) forthByte = str(0) subnetMask = (firstByte + '.' + secondByte + '.' + thirdByte + '.' + forthByte) for ID in range(inputSubnet): print ('10.' + idVarStr + '.0.' + '0') idVar += id idVarStr = str(idVar) if count == 1: firstByte = str(255) secondByte = str(255) thirdByte = str(bytes[dunamhSubnet]) forthByte = str(0) subnetMask = (firstByte + '.' + secondByte + '.' + thirdByte + '.' + forthByte) for ID in range(inputSubnet): print ('10.' + '0.' + idVarStr + '.0') idVar += id idVarStr = str(idVar) if count == 2: firstByte = str(255) secondByte = str(255) thirdByte = str(255) forthByte = str(bytes[dunamhSubnet]) subnetMask = (firstByte + '.' + secondByte + '.' + thirdByte + '.' + forthByte) for ID in range(inputSubnet): print ('10.' + '0.' + '0.' + idVarStr) idVar += id idVarStr = str(idVar) elif Class == "B Class": if count == 0: firstByte = str(255) secondByte = str(255) thirdByte = str(bytes[dunamhSubnet]) forthByte = str(0) subnetMask = (firstByte + '.' + secondByte + '.' + thirdByte + '.' + forthByte) for ID in range(inputSubnet): print ('172.' + '16.' + idVarStr + '.0') idVar += id idVarStr = str(idVar) elif count == 1: firstByte = str(255) secondByte = str(255) thirdByte = str(255) forthByte = str(bytes[dunamhSubnet]) subnetMask = (firstByte + '.' + secondByte + '.' + thirdByte + '.' + forthByte) for ID in range(inputSubnet): print ('172.' + '16.' + '0.' + idVarStr) idVar += id idVarStr = str(idVar) else: firstByte = str(255) secondByte = str(255) thirdByte = str(255) forthByte = str(bytes[dunamhSubnet]) subnetMask = (firstByte + '.' + secondByte + '.' + thirdByte + '.' + forthByte) for ID in range(inputSubnet): print ('192.' + '168.' + '0.' + idVarStr) idVar += id idVarStr = str(idVar) print ("Class: " + Class) print ("Subnet Mask: " + subnetMask) 环境中包含的图像的字幕字体大小吗?目前,html中的标题看起来像文本的其余部分。

3 个答案:

答案 0 :(得分:6)

这个答案显然已被接受,但为了完整起见,我正在添加问题的PDF方面。

如果您希望更改PDF文档的字幕字体大小,我建议您通过以下两种方法之一使用<GroupBox > <GroupBox.Header> <Border Background="Red"> <Label Content="Hello"></Label> </Border> </GroupBox.Header> </GroupBox> 包:

header-includes - 选项:

caption

此处的重点是--- title: "Title" author: "Jorge Luis Borges" header-includes: - \usepackage[font={small}]{caption} output: pdf_document ---

in_header - 选项:

font={<font options>}

其中--- title: "Title" author: "Jorge Luis Borges" output: pdf_document: includes: in_header: style.tex --- 包含在包含.Rmd文件的同一目录中。 style.tex文件需要包含style.tex

和以前一样,重点是\usepackage[font={small}]{caption}

使用font={<font options>}软件包,您有大量自定义选项,仅举几例,请参阅下文:

  • caption =非常小的尺寸
  • scriptsize =通常用于脚注的尺寸
  • footnotesize =小尺寸
  • small =大尺寸
  • large = italics
  • it =大胆的脸

如需完整参考,请访问official documentation

此外,这里有一些交叉参考文章在TexSE网站上:

Change the font of figure captions

How to include Latex package in RMarkdown

答案 1 :(得分:3)

你可以用css控制它。例如:

<style type="text/css">
.caption {
    font-size: x-small;
}
</style>

![caption](figure.jpg)

请参阅this等css指南,了解可用的font-size选项。

答案 2 :(得分:1)

由于@Johnny的早期评论,我希望在pdf报告中对图形标题进行更多修改。我希望标题看起来像这样:

  

图1 。这是一张解释生产率的图表。

要获取此信息,请添加YAML:

---
title: "Title"
author: "Author"
header-includes:
  - \usepackage[font={small,it}, labelfont={bf}]{caption}
output:
  pdf_document
---