答案1
你可以将minipage
环境与mdframed
包一起使用。当然,还有listings
代码的包。
此示例答案针对每个页面的边距进行了调整1.5cm
。如果您增加边距(减少内容的可用空间),您还应该修复\textwidth
小页面的边距。
由于右侧的迷你页面不是逐字逐句的,因此您需要手动在文本块之间添加空格,以便它们与另一侧匹配。以下代码中提供了如何执行此操作的示例。
输出
代码
\documentclass[a4paper]{article}
\usepackage[margin=1.5cm]{geometry}
\usepackage{listings,mdframed}
\usepackage{booktabs}
\lstset{basicstyle=\footnotesize\ttfamily,breaklines=true}
\begin{document}\footnotesize%
\begin{minipage}[t]{0.47\textwidth}%
\begin{mdframed}
\begin{lstlisting}[frame=none] % Start your code-block
% ----------------------
% BOUNDARY CONDITIONS
% ----------------------
B = 1.0E+06;
for I=1:NUMNP
if NPBC(I) == 1 | NPBC(I) == 3
I1 = 2*I-1;
SK(I1,1)=SK(I1,1)*B;
RHS(I1)=LHS(I1)*SK(I1,1);
end
if NPBC(I) == 2 | NPBC(I) == 3
I2=2*I;
SK(I2,1)=SK(I2,1)*B;
RHS(I2)=LHS(I2)*SK(I2,1),
end
end
% ----------------------
% CALL EQUATION SOLVER
% ----------------------
LHS = sGAUSS(SK,RHS,NUMEQ,IB);
% --------------------------
% Nodal values for w and dw/dx are now
% in LSH. Use this values to calculate
% shear and moment at center of element.
%
% First calculate shape functions
% and their derivatives. Ic is
% counter for number elements used
% --------------------------
\end{lstlisting}
\end{mdframed}
\end{minipage}%
\hspace{1mm}
\begin{minipage}[t]{0.45\textwidth}
\begin{mdframed}
\vspace{2mm}
Specify boundary conditions.\\
\begin{tabular}{ccccc}
NPBC & $w$ & $dw/dx$ & $V$ & $M$ \\ \midrule
0 & U & U & K & K \\
1 & K & U & U & K \\
2 & U & K & K & U \\
3 & K & K & U & U \\
\end{tabular}
\\[5mm]
where\\
K = known\\
U = unknown
\\[2cm]
Call equation solver for symmetric, banded storage.
\\[1cm]
Begin calculations of shear and bending moments at center of each element.
\end{mdframed}
\end{minipage}%
\hfill\null
\end{document}