我已经花了几天时间尝试在 tex 文件中动态地正确包含 Java 源文件。文本已包含。但是行不会换行。
以下是“缩水”的项目
\documentclass{article}
\usepackage[left=2.54cm, right=2.54cm, top=2.54cm, bottom=2.54cm]{geometry}
\usepackage{listings}
\usepackage{adjustbox}
\usepackage{wrapfig}
%%\usepackage[none]{hyphenat}
\usepackage[T1]{fontenc}
\usepackage[cp1252]{inputenc}
\usepackage{lmodern}
\usepackage[english]{babel}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{graphicx}
\graphicspath{{images/}{../images/}}
%% All duplicates have been commented out
\usepackage[ampersand]{easylist}
\usepackage{ulem}
\usepackage{csquotes}
\newcommand{\quotes}[1]{``#1''}
\usepackage{textcomp}
\usepackage{tikz}
\usetikzlibrary{calc, shapes, backgrounds}
\usepackage{amsmath, amssymb}
\usepackage{verbatim}
\usepackage{pdflscape}
\usepackage{wallpaper}
\usepackage{framed}
\usepackage{float}
\lstdefinestyle{MyJavaListStyle} {
numbers=left,
language=Java,
backgroundcolor={\color{yellow}},
breaklines=true
}
\usepackage{filecontents}
\begin{document}
Begining of the document.
\begin{filecontents*}{file.java}
}
static void testMe() {
String[][] arrTest = {
{ "John ", "Doe", "24a", "121", "new McGill College",
" a Suite 32", "2r223", "Montréal Name Of The Town1"
"", "Québec", "K1A 2E3W3", "Canada" },
{ "Zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzmabcdefghijklmnopqrstuvwxyzmabcdefghijklmnopqrs", "GivenNameZabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzmabcdefghijklmnopqrstuvwxyzmabcdefghij",
"24arererere_rerere",
"121ere",
"new McGill College McGill College McGill College McGill Collegea",
" a Suite 32", "2r223",
"Montréal Long City Name On My So So It Is Split onto",
"", "Québec", "K1A 2E3", "Canada" }, };
String cpfn = m_busCompCCP.getFieldValue("CIC EAI Person Family Name"); // **report**
String cpgn = m_busCompCCP.getFieldValue("CIC EAI Person Given Name") ; //**report**
String ctdob = m_busCompCCP.getFieldValue("CIC EAI Person Textual Birth Date"); // **report**
try {
oAR.sCICPrimaryGivenName = cpgn;
oAR.sCICTextualDOB = ctdob;
// we have the data, add-it to the
// result set
// addonlythearchived ones; redundant check, should have been
// filtered already at the search spec BC
//if (status.equals(archivedENU) || status.equals(archivedFRA))
listArchiveLabel.add(oAR);
} catch (Exception exa) {
System.out
.println("Error adding a row from the result set:"
+ exa.toString());
}
bFound6 = m_busCompCCP.nextRecord();
}
bFound5 = m_busCompCACO.nextRecord();
}
bFound4 = m_busCompCPOC.nextRecord() ;
}
bFound3 = m_busCompCAMC.nextRecord();
}
bFound2= m_busCompAMAR.nextRecord();
\end{filecontents*}
\begin{landscape}
$$Retrieve\ methods$$
\begin{framed}
\lstinputlisting[style=MyJavaListStyle,
linerange={1-549},
firstnumber=1,
caption=file.java,
]{file.java}
\end{framed}
\end{landscape}
Continuation of the document.
\end{document}
图片: