我有csv
如下文件:
sublime 中的文件csv
如下所示:
现在代码读取了quote
位于中心页脚的环境中的每个引文和作者。但它根本不打印文本。错误是什么?
以下是代码:
%Template for Technical Document
\documentclass{book}
\usepackage{graphicx}
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usepackage[a4paper,margin=1in,bindingoffset=0.2in,centering,headheight=0.3in,heightrounded]{geometry}
%\renewcommand{\chaptername}{Article}
\usepackage{fancyhdr}
\usepackage{datatool}
\usepackage[a4paper,margin=1in,bindingoffset=0.2in,centering,headheight=0.3in,heightrounded]{geometry}
% Can also use centering, or hcentering
\DTLloaddb[noheader,keys={,quote,author}]{quotes}{quotes.csv}
\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[LE,RO]{\tikz[baseline={(0,0)},anchor=center]
\node[label={center:\thepage}]{\includegraphics[scale=.25]{apple.jpg}};}%
\renewcommand{\footrulewidth}{0.4pt}
\renewcommand{\headrulewidth}{0.0pt}
}
\DTLforeach{quotes}{\q=quote,\a=author}{
\fancypagestyle{myfancy}{
\fancyhf{}
\fancyhead[LE,RO]{\slshape\nouppercase{\leftmark}}
\fancyfoot[LE,RO]{\tikz[baseline={(0,0)},anchor=center] \node[label={center:\thepage}]{\includegraphics[scale=.25]{apple}};}%
\fancyfoot[cf]{\begin{quote}{\a}
\q
\end{quote}
}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
}
}
\usepackage{microtype}
\usepackage{afterpage}
\let\oldcleardoublepage\cleardoublepage
\renewcommand{\cleardoublepage}{\afterpage{\thispagestyle{empty}}\oldcleardoublepage}
\pagestyle{myfancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\begin{document}
\chapter{Install Backtrack on an Android Device}
\section{What is Backtrack?}
BackTrack is a distribution designed by Jason Dennis based on the Ubuntu Linux distribution aimed at digital forensics and penetration testing use. BackTrack provides users with easy access to a comprehensive and large collection of security-related tools ranging from port scanners to Security Audit. Support for Live CD and Live USB functionality allows users to boot BackTrack directly from portable media without requiring installation, though permanent installation to hard disk and network is also an option.\par
\section{Security Tools in Backtrack}
BackTrack includes many well known security tools including:
\begin{itemize}
\item Metasploit for integration
\item Wi-Fi drivers supporting monitor mode (rfmon mode) and packet injection
\item Aircrack-ng
\item Gerix Wifi Cracker
\item Kismet
\item Nmap
\item Ophcrack
\item Ettercap
\item Wireshark (formerly known as Ethereal)
\item BeEF (Browser Exploitation Framework)
\item Hydra
\item OWASP Mantra Security Framework, a collection of hacking tools, add-ons and scripts based on FirefoX.
\item Cisco OCS Mass Scanner, a very reliable and fast scanner for Cisco routers with telnet and enabling of a default password.
\end{itemize}
\section{Installing Backtrack on Android Device}
\subsection{Tools Required}
\begin{enumerate}
\item Backtrack 5 ARM.\\
Download Backtrack 5 ARM from Backtrack official site. Backtrack with ARM architecture only on Backtrack 5 version. ARM architecture not available for Backtrack 5 R1, Backtrack 5 R2, and Backtrack 5 R3.
\item Rooted android device \\
Why rooted android device ? Because we need install some application that need Android to be root
\item Busybox, Superuser, Terminal Emulator, and AndroidVNC. \\
You can download search and all of them on Google Play. BusyBox is installer and uninstaller Android program, Superuser is superuser rights manager for Android, Terminal Emulator is Android's built-in Linux command line shell program, and AndroidVNC is a VNC viewer for Android.
\end{enumerate}
\subsection{Installation}
\begin{enumerate}
\item Extract BT5-GNOME-ARM.7z to folder, for example "BT5" folder and then put on device root directory.
\item Open Terminal Emulator on device then go to BT5 folder using the command \verb+ cd sdcard/BT5 +
\item Then run this following command \verb+ su + and \verb+ sh bootbt + and you will see \verb+ root@localhost +
\item Now lets run Backtrack GUI with VNC viewer \verb+startvnc+
\item To connect wth VNC we must know the port where VNC listening. Run \verb+netstat -anpt+ and remember the port where VNC listening. In this case the port is 59016. Open AndroidVNC and fill the form like this: \\
Nickname : BT5\\
Password : toortoor\\
Address : 127.0.0.1\\
Port : 5901 \\
\item Connect it and you will see Backtrack 5 interface \par
\textit{Remember! Some of the Backtrack tools can't work properly and do it for your own risk. I hope you can Install Backtrack on Android device without any problems, tell me if you get problems.}
\end{enumerate}
\end{document}
csv 文件:
quote,author
I think everybody in this country should learn how to program a computer because it teaches you how to think,Steve Jobs
Computer Science is no more about computers than astronomy is about telescopes,Edsger W. Dijkstra
The computer was born to solve problems that did not exist before,Bill Gates
A computer would deserve to be called intelligent if it could deceive a human into believing that it was human,Alan Turing
UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity,Dennis Ritchie
Imagination is more important than knowledge. For knowledge is limited, whereas imagination embraces the entire world, stimulating progress, giving birth to evolution,Albert Einstein
The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge,Stephen Hawking
The more you know, the more you realize you know nothing,Socrates
Tell me and I forget. Teach me and I remember. Involve me and I learn.,Benjamin Franklin
Real knowledge is to know the extent of one’s ignorance.,Confucius
I do not fear computers. I fear lack of them.,Isaac Asimov
以下是新更新的代码:
%Template for Technical Document
\documentclass{book}
\usepackage{graphicx}
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usepackage{suffix}
\usepackage[a4paper,margin=1in,bindingoffset=0.2in,centering,headheight=0.3in,heightrounded]{geometry}
%\renewcommand{\chaptername}{Article}
\usepackage{fancyhdr}
\usepackage[a4paper,margin=1in,bindingoffset=0.2in,centering,headheight=0.3in,heightrounded]{geometry}
% Can also use centering, or hcentering
\usepackage{datatool}
\usepackage[printwatermark]{xwatermark}
\usepackage{xcolor}
\usepackage{transparent}
\DTLloaddb{quotes}{quotes.csv}
\usetikzlibrary{shapes.misc,arrows}
\newcommand\titlebar{%
\tikz[baseline,trim left=0.5cm,trim right=2.5cm] {%
\node [
text = red!70!green,
anchor= base east,
minimum height=3.5ex] (a) at (2.5cm,0.6ex) {%
};
\path[fill=red!70!blue] (a.east) circle (.5ex);
\draw[color=red!70!blue, thick,rounded corners=1ex] (a.east) |- (\textwidth+3cm,-0.75ex);
}%
}
\newcommand\subtitlebar{%
\tikz[baseline,trim left=1cm,trim right=3.05cm] {%
\node[
text = red!70!green,
anchor= base east,
minimum height=3.5ex] (b) at (3.05cm,0.6ex) {%
};
\path[fill=red!70!blue] (b.east) circle (.5ex);
\draw[color=red!70!blue, thick,rounded corners=1ex] (b.east) |- (\textwidth+2cm,-0.75ex);
}%
}
\titleformat{\subsection}{\normalfont\sf}{\subtitlebar}{0.2cm}{\textcolor{blue!60!green}{#1}}
\titlespacing*{\subsection}{-2cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titlespacing*{name=\subsection,numberless}{0cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\renewcommand*{\thesubsection}{\arabic{subsection}}
\titleformat{\section}{\large\sf}{\titlebar}{0.25cm}{\textcolor{blue!60!green}{#1}}
\titlespacing*{\section}{-2.15cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titlespacing*{name=\section,numberless}{0cm}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\renewcommand*{\thesection}{\arabic{section}}
\newcommand\chapterauthor[1]{\authortoc{#1}\printchapterauthor{#1}}
\WithSuffix\newcommand\chapterauthor*[1]{\printchapterauthor{#1}}
\makeatletter
\newcommand{\printchapterauthor}[1]{%
{\parindent0pt\vspace*{-25pt}%
\linespread{1.5}\large\scshape\filcenter #1%
\par\nobreak\vspace*{35pt}}
\@afterheading%
}
\newcommand{\authortoc}[1]{%
\addtocontents{toc}{\vskip-10pt}%
\addtocontents{toc}{%
\protect\contentsline{chapter}%
{\hskip1.3em\mdseries\scshape\protect\scriptsize#1}{}{}}
\addtocontents{toc}{\vskip5pt}%
}
\makeatother
\titleformat{\chapter}[display]
{\bfseries\Large}
% {\filright\MakeUppercase{\chaptertitlename}\Huge\thechapter}
{}
{1ex}
{\titlerule\vspace{1ex}\filcenter #1}
[\vspace{1ex}\titlerule]
\DTLforeach{quotes}{
\q=quote, \a=author}{
\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[LE,RO]{\tikz[baseline={(0,0)},anchor=center]
\node[label={center:\thepage}]{\includegraphics[scale=.25]{apple}};}%
\fancyfoot[cf]{\q}
\renewcommand{\footrulewidth}{0.4pt}
\renewcommand{\headrulewidth}{0.0pt}
}
\fancypagestyle{myfancy}{
\fancyhf{}
\fancyhead[LE,RO]{\slshape\nouppercase{\leftmark}}
\fancyfoot[LE,RO]{\tikz[baseline={(0,0)},anchor=center] \node[label={center:\thepage}]{\includegraphics[scale=.25]{apple}};}%
\fancyfoot[cf]{\q}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
}
}
\usepackage{microtype}
\usepackage{afterpage}
\let\oldcleardoublepage\cleardoublepage
\renewcommand{\cleardoublepage}{\afterpage{\thispagestyle{empty}}\oldcleardoublepage}
\pagestyle{myfancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\newwatermark[allpages,color=red!50,scale=3,xpos=0,ypos=0]{\transparent{0.4}\includegraphics[scale=.25]{logo}}
\begin{document}
\chapter{Install Backtrack on an Android Device}
\chapterauthor*{K.DINESH KUMAR \par II Year B.Tech CSE}
\section{What is Backtrack?}
BackTrack is a distribution designed by Jason Dennis based on the Ubuntu Linux distribution aimed at digital forensics and penetration testing use. BackTrack provides users with easy access to a comprehensive and large collection of security-related tools ranging from port scanners to Security Audit. Support for Live CD and Live USB functionality allows users to boot BackTrack directly from portable media without requiring installation, though permanent installation to hard disk and network is also an option.\par
\section{Security Tools in Backtrack}
BackTrack includes many well known security tools including:
\begin{itemize}
\item Metasploit for integration
\item Wi-Fi drivers supporting monitor mode (rfmon mode) and packet injection
\item Aircrack-ng
\item Gerix Wifi Cracker
\item Kismet
\item Nmap
\item Ophcrack
\item Ettercap
\item Wireshark (formerly known as Ethereal)
\item BeEF (Browser Exploitation Framework)
\item Hydra
\item OWASP Mantra Security Framework, a collection of hacking tools, add-ons and scripts based on FirefoX.
\item Cisco OCS Mass Scanner, a very reliable and fast scanner for Cisco routers with telnet and enabling of a default password.
\end{itemize}
\section{Installing Backtrack on Android Device}
\subsection{Tools Required}
\begin{enumerate}
\item Backtrack 5 ARM.\\
Download Backtrack 5 ARM from Backtrack official site. Backtrack with ARM architecture only on Backtrack 5 version. ARM architecture not available for Backtrack 5 R1, Backtrack 5 R2, and Backtrack 5 R3.
\item Rooted android device \\
Why rooted android device ? Because we need install some application that need Android to be root
\item Busybox, Superuser, Terminal Emulator, and AndroidVNC. \\
You can download search and all of them on Google Play. BusyBox is installer and uninstaller Android program, Superuser is superuser rights manager for Android, Terminal Emulator is Android's built-in Linux command line shell program, and AndroidVNC is a VNC viewer for Android.
\end{enumerate}
\subsection{Installation}
\begin{enumerate}
\item Extract BT5-GNOME-ARM.7z to folder, for example "BT5" folder and then put on device root directory.
\item Open Terminal Emulator on device then go to BT5 folder using the command \verb+ cd sdcard/BT5 +
\item Then run this following command \verb+ su + and \verb+ sh bootbt + and you will see \verb+ root@localhost +
\item Now lets run Backtrack GUI with VNC viewer \verb+startvnc+
\item To connect wth VNC we must know the port where VNC listening. Run \verb+netstat -anpt+ and remember the port where VNC listening. In this case the port is 59016. Open AndroidVNC and fill the form like this: \\
Nickname : BT5\\
Password : toortoor\\
Address : 127.0.0.1\\
Port : 5901 \\
\item Connect it and you will see Backtrack 5 interface \par
\textit{Remember! Some of the Backtrack tools can't work properly and do it for your own risk. I hope you can Install Backtrack on Android device without any problems, tell me if you get problems.}
\end{enumerate}
\end{document}
苹果:
答案1
您的示例中的一些材料与每页打印引文的问题并不严格相关,因此我将其删除。但您可以使用包everypage
来datatool
执行您想要的操作。类似这样的操作将不断循环显示 中的 11 条引文,.csv
并在底部打印一条:
\documentclass{book}
\usepackage{filecontents}
\begin{filecontents}{quotations.csv}
I\space think everybody in this country should learn how to program a computer because it teaches you how to think.; Steve Jobs
Computer Science is no more about computers than astronomy is about telescopes.; Edsger W. Dijkstra
The computer was born to solve problems that did not exist before.; Bill Gates
A\space computer would deserve to be called intelligent if it could deceive a human into believing that it was human.; Alan Turing
UNIX is basically a simple operating system but you have to be a genius to understand the simplicity.; Dennis Ritchie
Imagination is more important than knowledge. For knowledge is limited, whereas imagination embraces the entire world, stimulating progress, giving birth to evolution.; Albert Einstein
The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge.; Stephen Hawking
The more you know, the more you realize you know nothing.; Socrates
Tell me and I forget. Teach me and I remember. Involve me and I learn.; Benjamin Franklin
Real knowledge is to know the extent of one's ignorance.; Confucius
I~do not fear computers. I fear lack of them.; Isaac Asimov
\end{filecontents}
\usepackage[T1]{fontenc}
\usepackage[a4paper,
% NOTE: margins at foot of page need to be calibrated to suit the size
% of 'apple.jpg'
margin=1in, includefoot, footskip=1in,
bindingoffset=0.2in,centering, headheight=0.3in,heightrounded,
]{geometry}
\usepackage{lipsum} % dummy text
\usepackage{everypage} % \AddEverypageHook
\usepackage{fancyhdr} % headers and footers
\usepackage{datatool} % access .csv
\DTLsetseparator{;} % use semi-colon as delimter (commas use in
% quotations)
\DTLloaddb[noheader,keys={quote,author}]{quotes}{quotations.csv}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\fancypagestyle{myfancy}{
\fancyhf{}
\fancyhead[LE,RO]{\leftmark}
% black box in place of image;
% replace with \includegraphics[<options>]{apple}
\fancyfoot[LE,RO]{\rule{2cm}{2cm}}
% print the value of \Value in footer
\fancyfoot[cf]{\Value}
}
% Create, initialize our counter;
\newcounter{thepagenum}
\setcounter{thepagenum}{0}
% Set highest row number to access
% '11' here because there are 11 rows in the .csv
\def\pagelimit{11}
% Set the size of the 'box' into which we shall put the quotation and
% author. The width of the box should be at least 4.5cm smaller than
% the \textwidth *IF* the size of the 'apple.jpg' is 2 cm wide. We set
% the height of the \parbox to 2cm *IF* that is the height of
% 'apple.jpg'
\newcommand{\setquoteandauthor}{%
\parbox[b][2cm][c]{\dimexpr\textwidth-4.5cm\relax}{\centering
\emph{\QValue} --- \AValue}}%
% At every new page:
% (1) Test value of 'thepagenum'; reset counter when the
% \pagelimit is reached.
% (2) Access the .csv and store the respective quotation in
% \QValue.
% (3) Print \QValue in footer.
\AddEverypageHook{%
\ifnum\pdfstrcmp{\arabic{thepagenum}}{\pagelimit}=0
\setcounter{thepagenum}{0}%
\else
\fi
\stepcounter{thepagenum}
\DTLgetvalue{\QValue}{quotes}{\arabic{thepagenum}}{1}%
% Author info too?
\DTLgetvalue{\AValue}{quotes}{\arabic{thepagenum}}{2}%
% \fancyfoot[cf]{``\QValue'' --- \AValue}%
\fancyfoot[cf]{\setquoteandauthor}}
\pagestyle{myfancy}
\begin{document}
\chapter{Install Backtrack on an Android Device}
\section{What is Backtrack?}
BackTrack is \lipsum[1-5]
\section{Security Tools in Backtrack}
\lipsum[1-5]
\section{Installing Backtrack on Android Device}
\subsection{Tools Required}
\lipsum[6-8]
\subsection{Installation}
\lipsum[1-60]
\lipsum[1-60]
\end{document}
需要注意的事项:
目前,在使用的页面上没有打印引文
\chapter
。我不确定所需的行为是什么。(此外,这些页面仍然“步进”计数器,因此您最终会跳过这些页面上的引文。) 新章节开始的页面上是否也应该有引文?我将分隔符改为
;
(参见\DTLsetseparator{;}
),因为一些引文本身带有逗号。由于某种我还没有探究过的原因,当引文以一个字母的单词(例如“I”或“A”)开头时,它与后面的单词之间的空格就会丢失。(参见第 1、4 和 11 行
.csv
。)
变化:
现在,每页的底部都使用引文和作者。
留出空间是为了在页脚中放置小图像。(目前,我已将其设置为绘制一个 2 厘米 x 2 厘米的黑色框。)这需要对页面底部进行适当的设置,
geometry
并将引文放在为图像留出空间的框中(参见\setquoteandauthor
)。