首页 > 其他分享 >Week 8 and 9 Literate programming

Week 8 and 9 Literate programming

时间:2024-09-04 17:24:46浏览次数:3  
标签:Week code Quarto Literate programming file import folder main

Week 8 and 9 Literate programming

(Communicating Results)

Pengfei Liu

1 Default setting of the Quarto Manuscript

1.1 Create the folder

(1) Create an empty folder for Quarto Manuscript and give it a proper name.

(2) Click File-New File-Quarto project-Manuscript project.

(3) Choose the folder we created in step 1.

1.2 Check the main YAML

(1) title:

(2) authors:

(3) bibliography: article citation

1.3 Check the structure of working folder

(1) _quarto.yml: format YAML. This is related to metadata and front matter of the

manuscript. Different formats of output are customized in this file.

(2) index.qmd: we write in this main document.

(3) references.bib: your references (which can be downloaded through Google Scholar or

through Zotero).

(4) Rename index.qmd as 0_main_file.qmd.

11.4 Generate two additional markdown files

Those additional markdown files conduct analysis that complement this main file.

1_generate_number: remember to put your affiliation here.

2_generate_figure: remember to put your affiliation here.

2 Edit YAML section and YAML file

2.1 Change the main file name in YAML

Please go to _quarto.yml to change the default file name to manuscript: article:

0_main_file.qmd.

2.2 Python engine

jupyter: python3

2.3 Affiliation

title: Assignment 3

affiliation: University of Auckland

email: xxxx

2.4 Date

date: last-modified

2.5 Abstract

abstract: Please put your absract of assignment 3 here. Example: This course will teach

you data science workflow. The course will focus on Python for Finance and reproducible

analytical pipeline.

22.6 keywords

Please put your keywords here

keywords: - Quarto - Manuscript

2.7 Add PDF as one of the output

Go to _quarto.yml

add pdf: default at the next level paramater of format:

comment out jats: default

3 Render the manuscript

3.1 First try

Click the preview button in Vscode.

Additional folders generated: .quarto, _manuscript, _freeze

_freeze: code is not re-evaluated unless their source changes. A corresponding _freeze folder

will be created.

3.2 Click on Word and PDF icon form your folder

Please go to the folder you created at step 1 of Section 1.1

This probably does not work.

Solution 1:  代 写Week 8 and 9 Literate programmingClick on Word and PDF icon within Vscode.

Solution 2: manually edit the format parameter within YAML.

3.3 Add number for each section

number-sections: true

34 Python code cells

4.1 Article Notebook: wrong way

If you only run the following code, The article notebook will not appear..

Mylist = [1,2,3,4]

4.2 Article Notebook: correct way

We have to print something or return an object to make Article Notebook show up.

[1, 2, 3, 4]

4.3 Echo code or not

In the code, we can add the following parameter to control whether code will be echoed in the

main text (not Article Notebook):

#| echo: true

More about code cells on the following page: https://quarto.org/docs/reference/cells/cells

jupyter.html

4.4 Output results or not

#| output: false

Mylist = [1,2,3,4]

Mylist

4.5 Other useful code cells parametrs

#| code-fold: true (Collapse code into an HTML tag)

#| code-line-numbers: true (Include line numbers in code block output)

45 Numbers, figures, and tables

5.1 Inline code for numbers

The average gap of eruption is 2.5.

5.2 External embeds: a figure

Let us import a figure created in another QMD file.

Figure 1: Timeline of recent earthquakes on La Palma

Embed: please refer to https://quarto.org/docs/authoring/notebook-embed.html for details

of how to use embeds in Quarto.

5.3 External embeds: specific folded line of code

Use the following code to import pandas:

import pandas as pd

import numpy as np

5.4 Display tables

An example adapted from Quarto documentation. Table 1 shows information related to dif

ferent car models.

Table 1: Example

mpg cylinders displacement horsepower weight

18

8

307

130 3504

15

8

350

165 3693

5Table 1: Example

mpg cylinders displacement horsepower weight

18

8

318

150 3436

16

8

304

150 3433

17

8

302

140 3449

15

8

429

198 4341

14

8

454

220 4354

14

8

440

215 4312

14

8

455

225 4425

15

8

390

190 3850

5.5 Add existing figures from a folder

Figure 2: A logo for BUSFIN 711

5.6 Cross References

We can cross-reference figures, tables, equations, sections, etc.

5.7 External embeds: several line of code

This is mainly for the purpose of demonstration:

6 1_generate_number

A (University of Auckland)

import pandas as pd

import numpy as np

67 Reference

Indirect citation: This is a simple placeholder for the manuscript’s main document (Knuth

1984).

Direct citation: Knuth (1984) is am important paper.

Add more references to references.bib file.

Acknowledgement: some of materials are adapted from Quarto official documentation.

Knuth, Donald E. 1984. “Literate Programming.” Comput. J. 27 (2): 97–111. https://doi.or

g/10.1093/comjnl/27.2.97.

7

标签:Week,code,Quarto,Literate,programming,file,import,folder,main
From: https://www.cnblogs.com/qq--99515681/p/18396990

相关文章

  • mini-lsm通关笔记Week1Day7
    Summary在上一章中,您已经构建了一个具有get/scan/put支持的存储引擎。在本周末,我们将实现SST存储格式的一些简单但重要的优化。欢迎来到Mini-LSM的第1周零食时间!在本章中,您将:在SST上实现布隆过滤器,并集成到LSM读路径get中。以SST块格式实现对key存储的压缩。要将测试用例......
  • mini-lsm通关笔记Week1Day6
    项目地址:https://github.com/skyzh/mini-lsm个人实现地址:https://gitee.com/cnyuyang/mini-lsmSummary在本章中,您将:使用L0flush实现LSM写路径。实现逻辑以正确更新LSM状态。要将测试用例复制到启动器代码中并运行它们,cargoxcopy-test--week1--day6cargoxsch......
  • 2019-2020 ICPC Northwestern European Regional Programming Contest (NWERC 2019):GH
    前言目前打过的最逆天的一场,前半场CF评测机度假去了,全场Inqueue,两小时左右评测机终于回来了,Standings遍地开花,听取WA声一片。昨天就有好几道题是因为没及时看题所以没做,赛后还和队友商量说应该先把所有题大致看一遍,结果今天不长记性,还没看H和J,就去写思路不一定对+实现起来难得......
  • SDKD 2024 Summer Training Contest F2(The 13th Shandong ICPC Provincial Collegiat
    A-Orders题意每天能生产k个产品的工厂有n个订单,第i个订单是在a_i天交b_i个产品,问能否交付。思路订单按日期排序,记录剩下的商品.代码#define_CRT_SECURE_NO_WARNINGS#include<bits/stdc++.h>usingnamespacestd;#defineintlonglongconstintmxn=1e6+5......
  • Hitachi Vantara Programming Contest 2024(AtCoder Beginner Contest 368)F - Dividing
    https://atcoder.jp/contests/abc368/tasks/abc368_f#include<bits/stdc++.h>#definexfirst#defineysecondusingnamespacestd;typedeflonglongll;typedefpair<ll,char>pii;constintN=2e5+10,inf=1e9;lln,m,k;intb[N],sg[N],a[N];vector......
  • BaseCTF2024-week2-Crypto部分题目wp
    先放一下官方的wp(我这里只放我出的题):https://j0zr0js7k7j.feishu.cn/wiki/JQbiwKdvtiR49VkMj5RcmPvPn7crandom_primesfromCrypto.Util.numberimport*importrandomdefgen_n():primes=[getPrime(128)for_inrange(256)]n=1foriinrange(100):......
  • mini-lsm通关笔记Week1Day5
    项目地址:https://github.com/skyzh/mini-lsm个人实现地址:https://gitee.com/cnyuyang/mini-lsmTask1-TwoMergeIterator在此任务中,您需要修改:src/iterators/two_merge_iterator.rs你已经在Week1Day2中实现了一个合并迭代器,它合并相同类型的迭代器(如:memtable迭代器)。既然......
  • Hitachi Vantara Programming Contest 2024(AtCoder Beginner Contest 368)题解A~D
    A-Cut题意:将数组的后k个字符移到前面思路:可以用rotate()函数让数组中的元素滚动旋转rotate(v.begin(),v.begin()+n-k,v.end());直接输出后k个元素,再输出前n-k个元素for(inti=n-k;i<n;i++)write(v[i]);for(inti=0;i<n-k;i++)write(v[i]);B-Decrease2......
  • 2024 National Invitational of CCPC (Zhengzhou), 2024 CCPC Henan Provincial Colle
    目录F优秀字符串J排列与合数H随机栈M有效算法AOnceInMyLifeB扫雷1LToxel与PCPCIIK树上问题D距离之比C中二病也要打比赛G扫雷2F优秀字符串签到,速杀。J排列与合数其实也是签到。全奇数情况的答案样例给了,含偶数的情况把偶数放最后即可。因为细节挂了两发......
  • Hitachi Vantara Programming Contest 2024(AtCoder Beginner Contest 368)- C
    题意概述有\(N\)个数,分别为\(H_1,H_2,H_3……H_N\)。你将使用初始化为\(0\)的变量\(T\)重复以下操作,直到所有数的值都变为\(0\)或更少。将\(T\)增加\(1\)。然后,减少最前方\(H_i\)值大于等于\(1\)的值。如果\(T\)是\(3\)的倍数,\(H_i\)的值会减少\(3\);......