[PATCH v2 4/8] styleguide: Add listing environment examples

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>From 33da9b7a0ee4c525b7cd7079722d5a40d5079f37 Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <akiyks@xxxxxxxxx>
Date: Thu, 20 Jul 2017 23:50:12 +0900
Subject: [PATCH v2 4/8] styleguide: Add listing environment examples

Add three examples:

  1) Caption at the bottom
  2) Caption at the top
  3) "Ruled" style

Example 2) and 3) change their looks by the floatrow's
"\thisfloatsetup{}" macro.

Signed-off-by: Akira Yokosawa <akiyks@xxxxxxxxx>
---
 appendix/styleguide/hello.c        |  9 +++++++
 appendix/styleguide/styleguide.tex | 48 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 55 insertions(+), 2 deletions(-)
 create mode 100644 appendix/styleguide/hello.c

diff --git a/appendix/styleguide/hello.c b/appendix/styleguide/hello.c
new file mode 100644
index 0000000..d35d93f
--- /dev/null
+++ b/appendix/styleguide/hello.c
@@ -0,0 +1,9 @@
+/*
+ * Sample Code Snippet
+ */
+#include <stdio.h>
+int main(void)
+{
+  printf("Hello world!\n");
+  return 0;
+}
diff --git a/appendix/styleguide/styleguide.tex b/appendix/styleguide/styleguide.tex
index 72b8ca0..b04b62b 100644
--- a/appendix/styleguide/styleguide.tex
+++ b/appendix/styleguide/styleguide.tex
@@ -589,8 +589,21 @@ This section lists up such candidates.
 Strictly speaking, code snippets are \emph{not} figures.
 They deserve their own floating environment.
 The ``floatrow'' package would be of help.
+Figure~\ref{fig:app:styleguide:Sample Code Snippet}
+can be typeset as in
+Listing~\ref{lst:app:styleguide:Sample Code Snippet}
+using an experimental environment ``listing''.
 
-% TODO: Add example
+\begin{listing}
+{ \scriptsize
+\verbfilebox[{\makebox[5ex][r]{\arabic{VerbboxLineNo}\hspace{2ex}}}]
+	{appendix/styleguide/hello.c}
+}
+\centering
+\theverbbox
+\caption{Sample Code Snippet}
+\label{lst:app:styleguide:Sample Code Snippet}
+\end{listing}
 
 \subsubsection{Position of Caption}
 \label{sec:app:styleguide:Position of Caption}
@@ -604,8 +617,39 @@ The same can be said of code snippets, which are read from
 top to bottom.
 The floatrow package mentioned above also has the capability
 to adjust layout of caption.
+For example,
+Listing~\ref{lst:app:styleguide:Sample Code Snippet (Top)}
+has the option \qco{cappostion=top} in its preamble.
 
-% TODO: Add example
+\begin{listing}\RawFloats
+{ \scriptsize
+\verbfilebox[{\makebox[5ex][r]{\arabic{VerbboxLineNo}\hspace{2ex}}}]
+	{appendix/styleguide/hello.c}
+}
+\begin{floatrow}[1]\thisfloatsetup{capposition=top}
+  \floatbox{listing}[2.5in]{\caption{Sample Code Snippet (Top)}
+    \label{lst:app:styleguide:Sample Code Snippet (Top)}}{
+\theverbbox
+}
+\end{floatrow}
+\end{listing}
+
+For code snippets, the ``ruled'' style would look even better.
+Listing~\ref{lst:app:styleguide:Sample Code Snippet (Ruled)}
+is an example using the option \qco{style=ruled}.
+
+\begin{listing}\RawFloats
+{ \scriptsize
+\verbfilebox[{\makebox[5ex][r]{\arabic{VerbboxLineNo}\hspace{2ex}}}]
+	{appendix/styleguide/hello.c}
+}
+\begin{floatrow}[1]\thisfloatsetup{style=ruled}
+  \floatbox{listing}[2.5in]{\caption{Sample Code Snippet (Ruled)}
+    \label{lst:app:styleguide:Sample Code Snippet (Ruled)}}{
+\theverbbox
+}
+\end{floatrow}
+\end{listing}
 
 Once the conversion of code sippets to a new environment has
 completed, we would be able to choose one of the style options
-- 
2.7.4


--
To unsubscribe from this list: send the line "unsubscribe perfbook" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux