summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/q-and-a
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-11-07 03:02:46 +0000
committerNorbert Preining <norbert@preining.info>2023-11-07 03:02:46 +0000
commit02646b6e89ef69971235e0c883e86fd746955e2b (patch)
tree203df1a9b40b37e9452e03d936e392da7d03c7af /macros/latex/contrib/q-and-a
parent240fd5fe8af67337e240c10434af4834fc86278f (diff)
CTAN sync 202311070302
Diffstat (limited to 'macros/latex/contrib/q-and-a')
-rw-r--r--macros/latex/contrib/q-and-a/Q-and-A.cls130
-rw-r--r--macros/latex/contrib/q-and-a/demo/lang-cn/Q-and-A-demo-cn-content.tex92
-rw-r--r--macros/latex/contrib/q-and-a/demo/lang-cn/Q-and-A-demo-cn.pdfbin0 -> 175682 bytes
-rw-r--r--macros/latex/contrib/q-and-a/demo/lang-cn/Q-and-A-demo-cn.tex28
-rw-r--r--macros/latex/contrib/q-and-a/demo/lang-cn/code/Q-and-A-demo-cn-code-for.py2
-rw-r--r--macros/latex/contrib/q-and-a/demo/lang-cn/code/Q-and-A-demo-cn-code-func.py4
-rw-r--r--macros/latex/contrib/q-and-a/demo/lang-cn/code/Q-and-A-demo-cn-code-list.py1
-rw-r--r--macros/latex/contrib/q-and-a/demo/lang-de/Q-and-A-demo-de-content.tex92
-rw-r--r--macros/latex/contrib/q-and-a/demo/lang-de/Q-and-A-demo-de.pdfbin0 -> 52791 bytes
-rw-r--r--macros/latex/contrib/q-and-a/demo/lang-de/Q-and-A-demo-de.tex28
-rw-r--r--macros/latex/contrib/q-and-a/demo/lang-de/code/Q-and-A-demo-de-code-for.py2
-rw-r--r--macros/latex/contrib/q-and-a/demo/lang-de/code/Q-and-A-demo-de-code-func.py4
-rw-r--r--macros/latex/contrib/q-and-a/demo/lang-de/code/Q-and-A-demo-de-code-list.py1
-rw-r--r--macros/latex/contrib/q-and-a/demo/lang-en/Q-and-A-demo-en-content.tex92
-rw-r--r--macros/latex/contrib/q-and-a/demo/lang-en/Q-and-A-demo-en.pdfbin0 -> 49773 bytes
-rw-r--r--macros/latex/contrib/q-and-a/demo/lang-en/Q-and-A-demo-en.tex26
-rw-r--r--macros/latex/contrib/q-and-a/demo/lang-en/code/Q-and-A-demo-en-code-for.py2
-rw-r--r--macros/latex/contrib/q-and-a/demo/lang-en/code/Q-and-A-demo-en-code-func.py4
-rw-r--r--macros/latex/contrib/q-and-a/demo/lang-en/code/Q-and-A-demo-en-code-list.py1
-rw-r--r--macros/latex/contrib/q-and-a/demo/lang-fr/Q-and-A-demo-fr.pdfbin48110 -> 48816 bytes
-rw-r--r--macros/latex/contrib/q-and-a/demo/lang-fr/Q-and-A-demo-fr.tex2
-rw-r--r--macros/latex/contrib/q-and-a/doc/Q-and-A-doc.pdfbin99039 -> 100627 bytes
-rw-r--r--macros/latex/contrib/q-and-a/doc/Q-and-A-doc.tex20
-rw-r--r--macros/latex/contrib/q-and-a/doc/code/Q-and-A-doc-code-sample-content-result.pdfbin21654 -> 21837 bytes
-rw-r--r--macros/latex/contrib/q-and-a/doc/code/Q-and-A-doc-code-sample-content-result.tex4
-rw-r--r--macros/latex/contrib/q-and-a/doc/code/Q-and-A-doc-code-sample-document.tex5
26 files changed, 500 insertions, 40 deletions
diff --git a/macros/latex/contrib/q-and-a/Q-and-A.cls b/macros/latex/contrib/q-and-a/Q-and-A.cls
index 20078cb62a..82e1cd7d5a 100644
--- a/macros/latex/contrib/q-and-a/Q-and-A.cls
+++ b/macros/latex/contrib/q-and-a/Q-and-A.cls
@@ -12,7 +12,7 @@
\NeedsTeXFormat{LaTeX2e}[2022-06-01]
\ProvidesExplClass
{Q-and-A}
- {2023/11/05} {}
+ {2023/11/07} {}
{Document class for typesetting Q&A conversation}
\keys_define:nn { Q-and-A }
@@ -33,6 +33,22 @@
, ChatGPT~dark .meta:n = { theme = ChatGPT-dark }
, ChatGPT dark .meta:n = { theme = ChatGPT-dark }
+ , numbered-question .bool_set:N = \l__QA_numbered_question_bool
+ , numbered-question .initial:n = { false }
+ , numbered~question .bool_set:N = \l__QA_numbered_question_bool
+ , numbered question .bool_set:N = \l__QA_numbered_question_bool
+ , question-number .bool_set:N = \l__QA_numbered_question_bool
+ , question~number .bool_set:N = \l__QA_numbered_question_bool
+ , question number .bool_set:N = \l__QA_numbered_question_bool
+
+ , numbered-answer .bool_set:N = \l__QA_numbered_answer_bool
+ , numbered-answer .initial:n = { false }
+ , numbered~answer .bool_set:N = \l__QA_numbered_answer_bool
+ , numbered answer .bool_set:N = \l__QA_numbered_answer_bool
+ , answer-number .bool_set:N = \l__QA_numbered_answer_bool
+ , answer~number .bool_set:N = \l__QA_numbered_answer_bool
+ , answer number .bool_set:N = \l__QA_numbered_answer_bool
+
, answer-outside-the-box .bool_set:N = \l__QA_answer_outside_the_box_bool
, answer-outside-the-box .initial:n = { false }
, answer~outside~the~box .bool_set:N = \l__QA_answer_outside_the_box_bool
@@ -153,7 +169,7 @@
}
\newlist { QA-entry } { description } { 1 }
-\setlist [ QA-entry ] { font = \normalfont\sffamily, leftmargin = \l_QA_list_indentation_dim, labelsep = \l_QA_list_labelsep_dim, labelwidth=!, parsep=\parskip }
+\setlist [ QA-entry ] { font = \normalfont\sffamily, leftmargin = \l_QA_list_indentation_dim, labelsep = \l_QA_list_labelsep_dim, labelwidth=3em, itemindent=0pt, parsep=\parskip }
\renewcommand{\descriptionlabel}[1]{#1}
\bool_new:N \l__QA_inside_list_bool
@@ -684,36 +700,84 @@
{
\tl_set:cn { l_QA_logo_code_ #1 _tl } { #2 }
}
+
% Set default logo code
\SetLogoCode[Q]{\textbf{\l_QA_label_Q_tl}}
\SetLogoCode[A]{\textbf{\l_QA_label_R_tl}}
-\projlib_langauge_define_multilingual_text:Nn \l_QA_label_Q_tl
+
+\newcounter{QA_Q}
+\newcounter{QA_A}
+\NewDocumentCommand \QAShowCounter { m }
+ {
+ \stepcounter{QA_#1}
+ \tl_use:c {theQA_#1}
+ }
+
+\bool_if:NTF \l__QA_numbered_question_bool
{
- , EN = { Q\,: }
- , FR = { Q: }
- , DE = { F\,: }
- , IT = { D\,: }
- , PT = { P\,: }
- , BR = { P\,: }
- , ES = { P\,: }
- , CN = { Q\,: }
- , TC = { Q\,: }
- , JP = { Q\,: }
- , RU = { B\,: }
- }
-\projlib_langauge_define_multilingual_text:Nn \l_QA_label_R_tl
+ \projlib_langauge_define_multilingual_text:Nn \l_QA_label_Q_tl
+ {
+ , EN = { Q \QAShowCounter{Q} \,: }
+ , FR = { Q \QAShowCounter{Q} : }
+ , DE = { F \QAShowCounter{Q} \,: }
+ , IT = { D \QAShowCounter{Q} \,: }
+ , PT = { P \QAShowCounter{Q} \,: }
+ , BR = { P \QAShowCounter{Q} \,: }
+ , ES = { P \QAShowCounter{Q} \,: }
+ , CN = { 问 \QAShowCounter{Q} \,:\hspace{-.5em} }
+ , TC = { 問 \QAShowCounter{Q} \,:\hspace{-.5em} }
+ , JP = { Q \QAShowCounter{Q} \,: }
+ , RU = { B \QAShowCounter{Q} \,: }
+ }
+ }
{
- , EN = { A\,: }
- , FR = { R: }
- , DE = { A\,: }
- , IT = { R\,: }
- , PT = { R\,: }
- , BR = { R\,: }
- , ES = { R\,: }
- , CN = { A\,: }
- , TC = { A\,: }
- , JP = { A\,: }
- , RU = { O\,: }
+ \projlib_langauge_define_multilingual_text:Nn \l_QA_label_Q_tl
+ {
+ , EN = { Q\,: }
+ , FR = { Q: }
+ , DE = { F\,: }
+ , IT = { D\,: }
+ , PT = { P\,: }
+ , BR = { P\,: }
+ , ES = { P\,: }
+ , CN = { 问\,:\hspace{-.33em} }
+ , TC = { 問\,:\hspace{-.33em} }
+ , JP = { Q\,: }
+ , RU = { B\,: }
+ }
+ }
+\bool_if:NTF \l__QA_numbered_answer_bool
+ {
+ \projlib_langauge_define_multilingual_text:Nn \l_QA_label_R_tl
+ {
+ , EN = { A \QAShowCounter{A} \,: }
+ , FR = { R \QAShowCounter{A} : }
+ , DE = { A \QAShowCounter{A} \,: }
+ , IT = { R \QAShowCounter{A} \,: }
+ , PT = { R \QAShowCounter{A} \,: }
+ , BR = { R \QAShowCounter{A} \,: }
+ , ES = { R \QAShowCounter{A} \,: }
+ , CN = { 答 \QAShowCounter{A} \,:\hspace{-.5em} }
+ , TC = { 答 \QAShowCounter{A} \,:\hspace{-.5em} }
+ , JP = { A \QAShowCounter{A} \,: }
+ , RU = { O \QAShowCounter{A} \,: }
+ }
+ }
+ {
+ \projlib_langauge_define_multilingual_text:Nn \l_QA_label_R_tl
+ {
+ , EN = { A\,: }
+ , FR = { R: }
+ , DE = { A\,: }
+ , IT = { R\,: }
+ , PT = { R\,: }
+ , BR = { R\,: }
+ , ES = { R\,: }
+ , CN = { 答\,:\hspace{-.33em} }
+ , TC = { 答\,:\hspace{-.33em} }
+ , JP = { A\,: }
+ , RU = { O\,: }
+ }
}
\prop_new:N \g__QA_prefix_type_prop
@@ -797,16 +861,16 @@
\AddLanguageSetting [ CN ]
{
\QARemoveAllPrefix
- \QASetTypePrefix { Q } { 问: , Q: , ? , ? }
- \QASetTypePrefix { A } { 答: , A: , : , : }
- \QASetTypePrefix { N } { 注: , N: , " , “ , ” , 「 }
+ \QASetTypePrefix { Q } { 问: , 问: , Q: , ? , ? }
+ \QASetTypePrefix { A } { 答: , 答: , A: , : , : }
+ \QASetTypePrefix { N } { 注: , 注: , N: , " , “ , ” , 「 }
}
\AddLanguageSetting [ TC ]
{
\QARemoveAllPrefix
- \QASetTypePrefix { Q } { 問: , Q: , ? , ? }
- \QASetTypePrefix { A } { 答: , A: , : , : }
- \QASetTypePrefix { N } { 註: , N: , " , “ , ” , 「 }
+ \QASetTypePrefix { Q } { 問: , 問: , Q: , ? , ? }
+ \QASetTypePrefix { A } { 答: , 答: , A: , : , : }
+ \QASetTypePrefix { N } { 註: , 註: , N: , " , “ , ” , 「 }
}
\AddLanguageSetting [ JP ]
{
diff --git a/macros/latex/contrib/q-and-a/demo/lang-cn/Q-and-A-demo-cn-content.tex b/macros/latex/contrib/q-and-a/demo/lang-cn/Q-and-A-demo-cn-content.tex
new file mode 100644
index 0000000000..6caa361359
--- /dev/null
+++ b/macros/latex/contrib/q-and-a/demo/lang-cn/Q-and-A-demo-cn-content.tex
@@ -0,0 +1,92 @@
+% 以下对话由 ChatGPT(使用 GPT-3.5)生成。
+
+Q:
+ 什么是计算机编程?
+
+A:
+ 计算机编程是为计算机创建指令以执行特定任务的过程。这是计算机科学领域的基本技能之一。编程涉及以计算机可理解的语言编写代码行。然后这些指令按顺序执行,允许执行各种操作,从简单的数学计算到管理复杂数据库或创建软件。
+
+Q:
+ 主要的编程语言有哪些?
+
+A:
+ 有许多编程语言,每种都有其自身的特点和特定的应用领域。一些常见的编程语言包括:
+
+ [Python]
+ 因其简单性和多功能性而备受赞誉,在数据科学、Web 开发和自动化领域广泛使用。
+
+ [Java]
+ 以其可移植性而闻名,用于 Android 应用程序开发、企业软件和嵌入式系统。
+
+ [C++]
+ 提供高性能,常用于游戏、桌面应用程序和实时系统。
+
+ [JavaScript]
+ 是 Web 开发的首选语言,运行在浏览器中,可创建交互式应用程序。
+
+ [Ruby]
+ 因其语法简单和优雅而备受赞誉,常用于 Web 开发和脚本编写。
+
+Q:
+ 如何在 Python 中编写 `for` 循环?
+
+A:
+ 在 Python 中,`for` 循环常用于迭代数据序列,如列表、字符串或字典。以下是 Python 中 `for` 循环的示例:
+
+ == [python] {code/Q-and-A-demo-cn-code-for.py}
+
+ 在此示例中,`for` 循环遍历从 0 到 4 的值,每次迭代时打印 `i` 的值。这使您能够高效执行重复的操作。
+
+Q:
+ 在 Python 中,什么是列表?
+
+A:
+ 在 Python 中,列表是一种数据结构,用于存储有序的元素集合。列表中的元素可以具有不同的类型,如数字、字符串,甚至其他列表。列表非常灵活多用,因此经常用于数据存储。以下是 Python 中列表的示例:
+
+ == [python] {code/Q-and-A-demo-cn-code-list.py}
+
+ 您可以使用它们的索引访问列表的元素。例如,`my\_list[2]` 将返回值 3,因为索引从 0 开始。
+
+Q:
+ 编程中局部变量和全局变量有什么区别?
+
+A:
+ 在编程中,变量的作用域是一个重要的概念。局部变量在函数内部声明,只能在该函数内部访问。它仅在函数执行期间存在,其名称与程序的其余部分隔离。相反,全局变量在所有函数外部声明,可以在程序的任何地方使用。它在函数调用之间保留其值,并可以被代码的任何部分修改。了解变量作用域对于避免代码中的意外错误至关重要。
+
+Q:
+ 如何在 Python 中声明函数?
+
+A:
+ 要在 Python 中声明函数,使用 `def` 关键字,后跟函数名称和参数。以下是一个函数声明的示例:
+
+ == [python] {code/Q-and-A-demo-cn-code-func.py}
+
+ 在此示例中,`my\_function` 是函数名称,它以 `parameter` 作为参数。函数内部执行操作,然后使用 `return` 关键字将结果值返回给调用者。函数对于组织代码并使其可重用非常重要。
+
+Q:
+ 解决编程问题的步骤是什么?
+
+A:
+ 解决编程问题包括多个关键步骤。
+
+ [理解问题]
+ [*] 确定目标。
+ [*] 分析输入数据。
+
+ [设计解决方案]
+ [*] 制定算法。
+ [*] 使用列表表示复杂的数据结构。
+
+ [编写代码]
+ [*] 将算法转化为代码。
+ [*] 使用列表和循环处理数据。
+
+ [测试和调试代码]
+ [*] 检查代码是否正确运行。
+ [*] 修复潜在错误(bug)。
+
+ [必要时进行优化]
+ [*] 改进代码效率。
+ [*] 使用高级技巧和列表以优化性能。
+
+ 这种结构化方法有助于程序员有效地解决计算机相关问题。
diff --git a/macros/latex/contrib/q-and-a/demo/lang-cn/Q-and-A-demo-cn.pdf b/macros/latex/contrib/q-and-a/demo/lang-cn/Q-and-A-demo-cn.pdf
new file mode 100644
index 0000000000..d8ac0d4a8e
--- /dev/null
+++ b/macros/latex/contrib/q-and-a/demo/lang-cn/Q-and-A-demo-cn.pdf
Binary files differ
diff --git a/macros/latex/contrib/q-and-a/demo/lang-cn/Q-and-A-demo-cn.tex b/macros/latex/contrib/q-and-a/demo/lang-cn/Q-and-A-demo-cn.tex
new file mode 100644
index 0000000000..40eeb71b0f
--- /dev/null
+++ b/macros/latex/contrib/q-and-a/demo/lang-cn/Q-and-A-demo-cn.tex
@@ -0,0 +1,28 @@
+\documentclass[%11pt,
+ numbered question,
+ numbered answer,
+ scroll,
+]{Q-and-A}
+
+\UseLanguage{Chinese}
+
+\begin{document}
+
+
+:: {Q-and-A-demo-cn-content}
+
+
+---
+
+"
+ 以下是这段对话的代码。
+
+ == {Q-and-A-demo-cn-content}
+
+"
+ 以下是主文档的代码。
+
+ == [latex] {\jobname}
+
+
+\end{document}
diff --git a/macros/latex/contrib/q-and-a/demo/lang-cn/code/Q-and-A-demo-cn-code-for.py b/macros/latex/contrib/q-and-a/demo/lang-cn/code/Q-and-A-demo-cn-code-for.py
new file mode 100644
index 0000000000..7049de3509
--- /dev/null
+++ b/macros/latex/contrib/q-and-a/demo/lang-cn/code/Q-and-A-demo-cn-code-for.py
@@ -0,0 +1,2 @@
+for i in range(5):
+ print(i) \ No newline at end of file
diff --git a/macros/latex/contrib/q-and-a/demo/lang-cn/code/Q-and-A-demo-cn-code-func.py b/macros/latex/contrib/q-and-a/demo/lang-cn/code/Q-and-A-demo-cn-code-func.py
new file mode 100644
index 0000000000..449d842a97
--- /dev/null
+++ b/macros/latex/contrib/q-and-a/demo/lang-cn/code/Q-and-A-demo-cn-code-func.py
@@ -0,0 +1,4 @@
+def my_function(parameter):
+ # 在函数内部执行操作
+ result = parameter * 2
+ return result \ No newline at end of file
diff --git a/macros/latex/contrib/q-and-a/demo/lang-cn/code/Q-and-A-demo-cn-code-list.py b/macros/latex/contrib/q-and-a/demo/lang-cn/code/Q-and-A-demo-cn-code-list.py
new file mode 100644
index 0000000000..b57a6ab114
--- /dev/null
+++ b/macros/latex/contrib/q-and-a/demo/lang-cn/code/Q-and-A-demo-cn-code-list.py
@@ -0,0 +1 @@
+my_list = [1, 2, 3, 4, 5] \ No newline at end of file
diff --git a/macros/latex/contrib/q-and-a/demo/lang-de/Q-and-A-demo-de-content.tex b/macros/latex/contrib/q-and-a/demo/lang-de/Q-and-A-demo-de-content.tex
new file mode 100644
index 0000000000..85e95d710e
--- /dev/null
+++ b/macros/latex/contrib/q-and-a/demo/lang-de/Q-and-A-demo-de-content.tex
@@ -0,0 +1,92 @@
+% Das folgende Gespräch wurde von ChatGPT (mit GPT-3.5) generiert.
+
+F:
+ Was ist Computerprogrammierung?
+
+A:
+ Die Computerprogrammierung ist der Prozess, Anweisungen für einen Computer zu erstellen, um spezifische Aufgaben auszuführen. Es ist eine der grundlegenden Fähigkeiten im Bereich der Informatik. Die Programmierung besteht darin, Zeilen von Code in einer für die Maschine verständlichen Sprache zu schreiben. Diese Anweisungen werden dann sequenziell ausgeführt und ermöglichen verschiedene Operationen, von einfachen mathematischen Berechnungen bis hin zur Verwaltung komplexer Datenbanken oder zur Erstellung von Software.
+
+F:
+ Was sind die wichtigsten Programmiersprachen?
+
+A:
+ Es gibt zahlreiche Programmiersprachen, jede mit ihren eigenen Merkmalen und spezifischen Anwendungsdomänen. Einige der häufigsten Programmiersprachen sind:
+
+ [Python]
+ Sehr geschätzt für seine Einfachheit und Vielseitigkeit, wird es weit verbreitet in der Datenwissenschaft, Webentwicklung und Automatisierung eingesetzt.
+
+ [Java]
+ Bekannt für seine Portabilität, wird es in der Entwicklung von Android-Apps, Unternehmenssoftware und eingebetteten Systemen verwendet.
+
+ [C++]
+ Es bietet hohe Leistung und wird häufig für Spiele, Desktop-Anwendungen und Echtzeitsysteme eingesetzt.
+
+ [JavaScript]
+ Die bevorzugte Sprache für die Webentwicklung, sie wird in Browsern ausgeführt und ermöglicht die Erstellung interaktiver Anwendungen.
+
+ [Ruby]
+ Geschätzt für seine syntaktische Einfachheit und Eleganz, wird es häufig in der Webentwicklung und Skripting eingesetzt.
+
+F:
+ Wie schreibt man eine `for`-Schleife in Python?
+
+A:
+ In Python werden `for`-Schleifen häufig verwendet, um über Datenfolgen wie Listen, Zeichenketten oder Wörterbücher zu iterieren. Hier ist ein Beispiel für eine `for`-Schleife in Python:
+
+ == [python] {code/Q-and-A-demo-de-code-for.py}
+
+ In diesem Beispiel durchläuft die `for`-Schleife Werte von 0 bis 4, und in jeder Iteration wird der Wert von `i` gedruckt. Dies ermöglicht die effiziente Ausführung wiederholter Operationen.
+
+F:
+ Was ist eine Liste in Python?
+
+A:
+ In Python ist eine Liste eine Datenstruktur, mit der Sie eine geordnete Sammlung von Elementen speichern können. Elemente in einer Liste können unterschiedliche Typen haben, wie Zahlen, Zeichenketten oder sogar andere Listen. Listen sind sehr flexibel und vielseitig, weshalb sie eine häufige Wahl für die Datenspeicherung sind. Hier ist ein Beispiel für eine Liste in Python:
+
+ == [python] {code/Q-and-A-demo-de-code-list.py}
+
+ Sie können auf Elemente der Liste zugreifen, indem Sie ihren Index verwenden. Zum Beispiel würde `meine\_liste[2]` den Wert 3 zurückgeben, da die Indizes bei 0 beginnen.
+
+F:
+ Was ist der Unterschied zwischen einer lokalen und einer globalen Variablen in der Programmierung?
+
+A:
+ In der Programmierung ist der Gültigkeitsbereich von Variablen ein wichtiger Begriff. Eine lokale Variable wird innerhalb einer Funktion deklariert und ist nur innerhalb dieser Funktion zugänglich. Sie existiert nur während der Ausführung der Funktion, und ihr Name ist vom Rest des Programms isoliert. Im Gegensatz dazu wird eine globale Variable außerhalb aller Funktionen deklariert und kann überall im Programm verwendet werden. Sie behält ihren Wert zwischen Funktionsaufrufen bei und kann von jedem Teil des Codes geändert werden. Das Verständnis des Variablenbereichs ist entscheidend, um unerwartete Fehler in Ihrem Code zu vermeiden.
+
+F:
+ Wie deklariert man eine Funktion in Python?
+
+A:
+ Um eine Funktion in Python zu deklarieren, verwenden Sie das Schlüsselwort `def`, gefolgt vom Namen der Funktion und ihren Parametern. Hier ist ein Beispiel für die Deklaration einer Funktion:
+
+ == [python] {code/Q-and-A-demo-de-code-func.py}
+
+ In diesem Beispiel ist `meine\_funktion` der Name der Funktion, und sie nimmt `parameter` als Argument. Innerhalb der Funktion werden Operationen durchgeführt, und der resultierende Wert wird an den Aufrufer mit dem Schlüsselwort `return` zurückgegeben. Funktionen sind entscheidend, um den Code zu organisieren und wiederzuverwenden.
+
+F:
+ Welche Schritte sind erforderlich, um ein Programmierproblem zu lösen?
+
+A:
+ Die Lösung eines Programmierproblems umfasst mehrere wesentliche Schritte.
+
+ [Das Problem verstehen]
+ [*] Ziele identifizieren.
+ [*] Eingabedaten analysieren.
+
+ [Eine Lösung entwerfen]
+ [*] Einen Algorithmus entwickeln.
+ [*] Listen zur Darstellung komplexer Datenstrukturen verwenden.
+
+ [Den Code schreiben]
+ [*] Den Algorithmus in Code umsetzen.
+ [*] Listen und Schleifen verwenden, um Daten zu verarbeiten.
+
+ [Den Code testen und debuggen]
+ [*] Überprüfen, ob der Code korrekt funktioniert.
+ [*] Eventuelle Fehler (Bugs) beheben.
+
+ [Optimieren, wenn erforderlich]
+ [*] Die Codeeffizienz verbessern.
+ [*] Fortgeschrittene Techniken mit Listen verwenden, um die Leistung zu optimieren.
+
+ Diese strukturierte Herangehensweise hilft Programmierern dabei, Computerprobleme effektiv zu lösen.
diff --git a/macros/latex/contrib/q-and-a/demo/lang-de/Q-and-A-demo-de.pdf b/macros/latex/contrib/q-and-a/demo/lang-de/Q-and-A-demo-de.pdf
new file mode 100644
index 0000000000..e5bc82799b
--- /dev/null
+++ b/macros/latex/contrib/q-and-a/demo/lang-de/Q-and-A-demo-de.pdf
Binary files differ
diff --git a/macros/latex/contrib/q-and-a/demo/lang-de/Q-and-A-demo-de.tex b/macros/latex/contrib/q-and-a/demo/lang-de/Q-and-A-demo-de.tex
new file mode 100644
index 0000000000..97380b0453
--- /dev/null
+++ b/macros/latex/contrib/q-and-a/demo/lang-de/Q-and-A-demo-de.tex
@@ -0,0 +1,28 @@
+\documentclass[%11pt,
+ numbered question,
+ numbered answer,
+ scroll,
+]{Q-and-A}
+
+\UseLanguage{German}
+
+\begin{document}
+
+
+:: {Q-and-A-demo-de-content}
+
+
+---
+
+"
+ Hier ist der Code dieses Gesprächs.
+
+ == {Q-and-A-demo-de-content}
+
+"
+ Hier ist der Code des Hauptdokuments.
+
+ == [latex] {\jobname}
+
+
+\end{document}
diff --git a/macros/latex/contrib/q-and-a/demo/lang-de/code/Q-and-A-demo-de-code-for.py b/macros/latex/contrib/q-and-a/demo/lang-de/code/Q-and-A-demo-de-code-for.py
new file mode 100644
index 0000000000..7049de3509
--- /dev/null
+++ b/macros/latex/contrib/q-and-a/demo/lang-de/code/Q-and-A-demo-de-code-for.py
@@ -0,0 +1,2 @@
+for i in range(5):
+ print(i) \ No newline at end of file
diff --git a/macros/latex/contrib/q-and-a/demo/lang-de/code/Q-and-A-demo-de-code-func.py b/macros/latex/contrib/q-and-a/demo/lang-de/code/Q-and-A-demo-de-code-func.py
new file mode 100644
index 0000000000..6eea5e601e
--- /dev/null
+++ b/macros/latex/contrib/q-and-a/demo/lang-de/code/Q-and-A-demo-de-code-func.py
@@ -0,0 +1,4 @@
+def meine_funktion(parameter):
+ # Führen Sie Operationen innerhalb der Funktion durch
+ ergebnis = parameter * 2
+ return ergebnis \ No newline at end of file
diff --git a/macros/latex/contrib/q-and-a/demo/lang-de/code/Q-and-A-demo-de-code-list.py b/macros/latex/contrib/q-and-a/demo/lang-de/code/Q-and-A-demo-de-code-list.py
new file mode 100644
index 0000000000..dc5dc91a3b
--- /dev/null
+++ b/macros/latex/contrib/q-and-a/demo/lang-de/code/Q-and-A-demo-de-code-list.py
@@ -0,0 +1 @@
+meine_liste = [1, 2, 3, 4, 5] \ No newline at end of file
diff --git a/macros/latex/contrib/q-and-a/demo/lang-en/Q-and-A-demo-en-content.tex b/macros/latex/contrib/q-and-a/demo/lang-en/Q-and-A-demo-en-content.tex
new file mode 100644
index 0000000000..dfe8970825
--- /dev/null
+++ b/macros/latex/contrib/q-and-a/demo/lang-en/Q-and-A-demo-en-content.tex
@@ -0,0 +1,92 @@
+% The following conversation is generated by ChatGPT (with GPT-3.5).
+
+Q:
+ What is computer programming?
+
+A:
+ Computer programming is the process of creating instructions for a computer to perform specific tasks. It is one of the fundamental skills in the field of computer science. Programming involves writing lines of code in a language understandable by the machine. These instructions are then executed sequentially, allowing for various operations, from simple mathematical calculations to managing complex databases or creating software.
+
+Q:
+ What are the main programming languages?
+
+A:
+ There are numerous programming languages, each with its own characteristics and specific application domains. Some of the most common programming languages include:
+
+ [Python]
+ Highly appreciated for its simplicity and versatility, it is widely used in data science, web development, and automation.
+
+ [Java]
+ Known for its portability, it is used in Android app development, enterprise software, and embedded systems.
+
+ [C++]
+ It offers high performance and is commonly used for games, desktop applications, and real-time systems.
+
+ [JavaScript]
+ The language of choice for web development, it runs in browsers and allows for creating interactive applications.
+
+ [Ruby]
+ Appreciated for its syntactical simplicity and elegance, it is commonly used in web development and scripting.
+
+Q:
+ How do you write a `for` loop in Python?
+
+A:
+ In Python, `for` loops are commonly used to iterate over data sequences, such as lists, strings, or dictionaries. Here's an example of a `for` loop in Python:
+
+ == [python] {code/Q-and-A-demo-en-code-for.py}
+
+ In this example, the `for` loop iterates through values from 0 to 4, and at each iteration, the value of `i` is printed. This allows you to perform repetitive operations efficiently.
+
+Q:
+ What is a list in Python?
+
+A:
+ In Python, a list is a data structure that allows you to store an ordered collection of elements. Elements in a list can be of different types, such as numbers, strings, or even other lists. Lists are very flexible and versatile, making them a common choice for data storage. Here's an example of a list in Python:
+
+ == [python] {code/Q-and-A-demo-en-code-list.py}
+
+ You can access elements of the list using their index; for example, `my\_list[2]` would return the value 3 because indices start at 0.
+
+Q:
+ What is the difference between a local variable and a global variable in programming?
+
+A:
+ In programming, the scope of variables is an important concept. A local variable is declared inside a function and is only accessible within that function. It exists only during the execution of the function, and its name is isolated from the rest of the program. In contrast, a global variable is declared outside of all functions and can be used anywhere in the program. It retains its value between function calls and can be modified by any part of the code. Understanding variable scope is essential to avoid unexpected errors in your code.
+
+Q:
+ How do you declare a function in Python?
+
+A:
+ To declare a function in Python, use the `def` keyword followed by the function name and its parameters. Here's an example of a function declaration:
+
+ == [python] {code/Q-and-A-demo-en-code-func.py}
+
+ In this example, `my\_function` is the function name, and it takes a `parameter` as an argument. Inside the function, operations are performed, and the resulting value is returned to the caller using the `return` keyword. Functions are essential for organizing code and making it reusable.
+
+Q:
+ What are the steps to solve a programming problem?
+
+A:
+ Solving a programming problem involves several essential steps.
+
+ [Understand the Problem]
+ [*] Identify the objectives.
+ [*] Analyze input data.
+
+ [Design a Solution]
+ [*] Develop an algorithm.
+ [*] Use lists to represent complex data structures.
+
+ [Write the Code]
+ [*] Transform your algorithm into code.
+ [*] Use lists and loops to process data.
+
+ [Test and Debug the Code]
+ [*] Check if the code works correctly.
+ [*] Fix any potential errors (bugs).
+
+ [Optimize if Necessary]
+ [*] Improve code efficiency.
+ [*] Use advanced techniques with lists to optimize performance.
+
+ This structured approach helps programmers effectively solve computer-related problems.
diff --git a/macros/latex/contrib/q-and-a/demo/lang-en/Q-and-A-demo-en.pdf b/macros/latex/contrib/q-and-a/demo/lang-en/Q-and-A-demo-en.pdf
new file mode 100644
index 0000000000..289a8e4e1a
--- /dev/null
+++ b/macros/latex/contrib/q-and-a/demo/lang-en/Q-and-A-demo-en.pdf
Binary files differ
diff --git a/macros/latex/contrib/q-and-a/demo/lang-en/Q-and-A-demo-en.tex b/macros/latex/contrib/q-and-a/demo/lang-en/Q-and-A-demo-en.tex
new file mode 100644
index 0000000000..d39626a9dd
--- /dev/null
+++ b/macros/latex/contrib/q-and-a/demo/lang-en/Q-and-A-demo-en.tex
@@ -0,0 +1,26 @@
+\documentclass[%11pt,
+ numbered question,
+ numbered answer,
+ scroll,
+]{Q-and-A}
+
+\begin{document}
+
+
+:: {Q-and-A-demo-en-content}
+
+
+---
+
+"
+ Below is the code of this conversation.
+
+ == {Q-and-A-demo-en-content}
+
+"
+ Below is the code of the main document.
+
+ == [latex] {\jobname}
+
+
+\end{document}
diff --git a/macros/latex/contrib/q-and-a/demo/lang-en/code/Q-and-A-demo-en-code-for.py b/macros/latex/contrib/q-and-a/demo/lang-en/code/Q-and-A-demo-en-code-for.py
new file mode 100644
index 0000000000..7049de3509
--- /dev/null
+++ b/macros/latex/contrib/q-and-a/demo/lang-en/code/Q-and-A-demo-en-code-for.py
@@ -0,0 +1,2 @@
+for i in range(5):
+ print(i) \ No newline at end of file
diff --git a/macros/latex/contrib/q-and-a/demo/lang-en/code/Q-and-A-demo-en-code-func.py b/macros/latex/contrib/q-and-a/demo/lang-en/code/Q-and-A-demo-en-code-func.py
new file mode 100644
index 0000000000..a7a8f99b20
--- /dev/null
+++ b/macros/latex/contrib/q-and-a/demo/lang-en/code/Q-and-A-demo-en-code-func.py
@@ -0,0 +1,4 @@
+def my_function(parameter):
+ # Perform operations inside the function
+ result = parameter * 2
+ return result \ No newline at end of file
diff --git a/macros/latex/contrib/q-and-a/demo/lang-en/code/Q-and-A-demo-en-code-list.py b/macros/latex/contrib/q-and-a/demo/lang-en/code/Q-and-A-demo-en-code-list.py
new file mode 100644
index 0000000000..b57a6ab114
--- /dev/null
+++ b/macros/latex/contrib/q-and-a/demo/lang-en/code/Q-and-A-demo-en-code-list.py
@@ -0,0 +1 @@
+my_list = [1, 2, 3, 4, 5] \ No newline at end of file
diff --git a/macros/latex/contrib/q-and-a/demo/lang-fr/Q-and-A-demo-fr.pdf b/macros/latex/contrib/q-and-a/demo/lang-fr/Q-and-A-demo-fr.pdf
index a1307f1deb..6713a86cf5 100644
--- a/macros/latex/contrib/q-and-a/demo/lang-fr/Q-and-A-demo-fr.pdf
+++ b/macros/latex/contrib/q-and-a/demo/lang-fr/Q-and-A-demo-fr.pdf
Binary files differ
diff --git a/macros/latex/contrib/q-and-a/demo/lang-fr/Q-and-A-demo-fr.tex b/macros/latex/contrib/q-and-a/demo/lang-fr/Q-and-A-demo-fr.tex
index 4f5ae4eded..140fafde78 100644
--- a/macros/latex/contrib/q-and-a/demo/lang-fr/Q-and-A-demo-fr.tex
+++ b/macros/latex/contrib/q-and-a/demo/lang-fr/Q-and-A-demo-fr.tex
@@ -1,4 +1,6 @@
\documentclass[%11pt,
+ numbered question,
+ numbered answer,
scroll,
]{Q-and-A}
diff --git a/macros/latex/contrib/q-and-a/doc/Q-and-A-doc.pdf b/macros/latex/contrib/q-and-a/doc/Q-and-A-doc.pdf
index 6c884038c4..dadca3b63e 100644
--- a/macros/latex/contrib/q-and-a/doc/Q-and-A-doc.pdf
+++ b/macros/latex/contrib/q-and-a/doc/Q-and-A-doc.pdf
Binary files differ
diff --git a/macros/latex/contrib/q-and-a/doc/Q-and-A-doc.tex b/macros/latex/contrib/q-and-a/doc/Q-and-A-doc.tex
index 5405916bad..48894878d7 100644
--- a/macros/latex/contrib/q-and-a/doc/Q-and-A-doc.tex
+++ b/macros/latex/contrib/q-and-a/doc/Q-and-A-doc.tex
@@ -1,9 +1,11 @@
\documentclass[%11pt,
use style = classical,
+ % numbered answer,
+ % numbered question,
scroll,
]{Q-and-A}
-\def\PackageVersion{2023/11/05}
+\def\PackageVersion{2023/11/07}
\def\PackageSubVersion{}
\newcommand{\QApackage}{{\normalfont\textsf{Q-and-A}}}
@@ -69,9 +71,11 @@
The available class options include:
\begin{itemize}
\item Font size options such as `11pt`, `12pt`.
- \item `scroll`: turns the scroll mode on, which generates a single-page pdf similar to a long screenshot. It is recommended to use this option if your document contains some large piece of code.
+ \item `scroll`: turn the scroll mode on, which generates a single-page pdf similar to a long screenshot. It is recommended to use this option if your document contains some large piece of code.
\item `use theme = \meta{theme}`: use the selected theme, available choices include: `default` (like the current document), `ChatGPT-light` and `ChatGPT-dark` (see the demo documents).
- \item `answer outside the box`, or `answer out of the box` (or even omit `the`): enables another implementation for printing the answer that does not involve putting it into a colored box. This would be useful if the answers contain many long pieces of code while you still want the pages to break normally.
+ \item `numbered question`, or `question number`: enable the numbering of questions.
+ \item `numbered answer`, or `answer number`: enable the numbering of answers.
+ \item `answer outside the box`, or `answer out of the box` (or even omit `the`): enable another implementation for printing the answer that does not involve putting it into a colored box. This would be useful if the answers contain many long pieces of code while you still want the pages to break normally.
\end{itemize}
?
@@ -221,8 +225,14 @@
\item Use `\textbackslash SetLogoCode\{Q\}\{\meta{logo code}\}` to set the labels for questions.
\item Use `\textbackslash SetLogoCode\{A\}\{\meta{logo code}\}` to set the labels for answers.
\end{itemize}
- Here, \meta{logo code} is the actual code for displaying the corresponding label. For example, the default label for questions is preset via `\textbackslash SetLogoCode\{Q\}\{\textbackslash textbf\{Q\textbackslash,:\}\}`.
- >>> In the demo document, you can find an example on how to use this command to specify a logo for each role in the conversation.
+ Here, \meta{logo code} is the actual code for displaying the corresponding label. For example, the default label for (unnumbered) questions is preset via `\textbackslash SetLogoCode\{Q\}\{\textbackslash textbf\{Q\textbackslash,:\}\}`.
+ \QANote{In the demo document, you can find an example on how to use this command to specify a logo for each role in the conversation.}
+ If you wish to include the question number or answer number, you may use the command `\textbackslash QAShowCounter`:
+ \begin{itemize}
+ \item Use `\textbackslash QAShowCounter\{Q\}` to step the counter of question and print it.
+ \item Use `\textbackslash QAShowCounter\{A\}` to step the counter of answer and print it.
+ \end{itemize}
+ For example, the default label for numbered questions is preset by adding `\textbackslash QAShowCounter\{Q\}` to the unnumbered version: `\textbackslash SetLogoCode\{Q\}\{\textbackslash textbf\{Q\textbackslash QAShowCounter\{Q\}\textbackslash,:\}\}`.
##+ {Known Issues}
diff --git a/macros/latex/contrib/q-and-a/doc/code/Q-and-A-doc-code-sample-content-result.pdf b/macros/latex/contrib/q-and-a/doc/code/Q-and-A-doc-code-sample-content-result.pdf
index 1b5660f6b2..24a795b3ca 100644
--- a/macros/latex/contrib/q-and-a/doc/code/Q-and-A-doc-code-sample-content-result.pdf
+++ b/macros/latex/contrib/q-and-a/doc/code/Q-and-A-doc-code-sample-content-result.pdf
Binary files differ
diff --git a/macros/latex/contrib/q-and-a/doc/code/Q-and-A-doc-code-sample-content-result.tex b/macros/latex/contrib/q-and-a/doc/code/Q-and-A-doc-code-sample-content-result.tex
index 9323cc5037..09a9f712e8 100644
--- a/macros/latex/contrib/q-and-a/doc/code/Q-and-A-doc-code-sample-content-result.tex
+++ b/macros/latex/contrib/q-and-a/doc/code/Q-and-A-doc-code-sample-content-result.tex
@@ -1,8 +1,10 @@
\documentclass[%11pt,
+ numbered answer,
+ numbered question,
% scroll,
]{Q-and-A}
-\geometry{paperwidth=12cm, paperheight=7.2cm}
+\geometry{paperwidth=12cm, paperheight=8.2cm}
\begin{document}
diff --git a/macros/latex/contrib/q-and-a/doc/code/Q-and-A-doc-code-sample-document.tex b/macros/latex/contrib/q-and-a/doc/code/Q-and-A-doc-code-sample-document.tex
index 7d4f6bc6ae..29aa3599e1 100644
--- a/macros/latex/contrib/q-and-a/doc/code/Q-and-A-doc-code-sample-document.tex
+++ b/macros/latex/contrib/q-and-a/doc/code/Q-and-A-doc-code-sample-document.tex
@@ -1,7 +1,10 @@
\documentclass[%11pt,
use theme = (@@@\meta{theme}),
+ numbered question,
+ numbered answer,
+ % answer outside the box,
scroll,
-]{Q-A}
+]{Q-and-A}
\UseLanguage{(@@@\meta{language})} % For English this line can be omitted.