0
我使用下面的代碼,它使用\ newcommand(宏):如何添加新命令的空白行中乳膠
\documentclass[12pt]{article}
\usepackage{color}
\usepackage{graphicx}
\begin{document}
% definition of new commands:
\newcommand{\mytitle}[1]{\LARGE\color{black}\centering\textbf{#1\newline}}
% NEWLINE WORKS IN ABOVE LINE
\newcommand{\mycode}{\small\color{green}Code:\scriptsize\leftskip30pt\color{red}\\*}%
% CANNOT ADD NEWLINE BEFORE "Code:" IN ABOVE LINE
\newcommand{\mytext}{\normalsize\color{black}\leftskip0pt}
\newcommand{\myoutput}{\small\color{green}Output:\scriptsize\leftskip30pt\color{blue}\\}%
% CANNOT ADD NEWLINE BEFORE "Output:" IN ABOVE LINE
\quote % to prevent indentation of first line;
% main text starts here:
\mytitle{Simple text, code and figure.}
\mytext
This is normal text- part 1.\\
This is normal text- part 1.\\
This is normal text- part 1.\\
\mycode
This is code line 1.\\
This is code line 2.\\
This is code line 3.\\
\myoutput
This is output line 1.\\
This is output line 2.\\
This is output line 3.\\
\mytext
This is normal text- part 2.\\
This is normal text- part 2.\\
This is normal text- part 2.\\
\mycode
This is code part 2.\\
This is code part 2.\\
This is code part 2.\\
\myoutput
This is output part 2.\\
This is output part 2.\\
This is output part 2.\\
\mytext
The last line in normal text.\\
\end{document}
雖然輸出是不錯,我以前無法進入的空行「代碼」,‘輸出’和文字部分構成:
我曾嘗試使用\\
\newline
和\linebreak[1]
在以箭頭標出點加空行,但它們都產生以下錯誤:
There's no line here to end.
如何在代碼,輸出和文本的文本部分之前添加空白行?謝謝你的幫助。