如何在Bookdown中编写伪代码

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

我想在我的bookdown项目中添加一个带伪代码的代码块,但我没有找到一个正确的方法来做到这一点。

关于github/bookdown这个老问题,他们谈论这个功能,但我没有发现任何新的东西。

在这个tex.stackexchange帖子中,他们通过乳胶生成伪代码,在Rmd文件中被忽略。

```{}
**INPUT:** input;  
**OUTPUT:** result;  

**IF** this_is_True:  
  do_this;  
**ELSE**
  select B from input;  
  do something whith input;  
  **FOR EACH** $a_i$ **in** B   
    do something with $a_i$;
```

代码显示了一个我希望在此转换的示例块:

目前它忽略了markdown和qazxsw poi符号来进行数学表达(字母'a'带有小索引i)。

最好的祝福 拉尔夫

更新29.04 - 来自Rmd文件的示例代码块,并添加一个简单的预期输出

r r-markdown bookdown
1个回答
0
投票

$怎么样:

line blocks

HTML输出:

--- output: pdf_document: default html_document: default --- | **INPUT:** input; | **OUTPUT:** result; | | **IF** this_is_True: | do_this; | **ELSE** | select B from input; | do something whith input; | **FOR EACH** $a_i$ **in** B | do something with $a_i$;

PDF输出:

enter image description here

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