我已经定义了这样的新命令:
def\inline#1{\lstinline[breaklines=true, basicstyle=\ttfamily]{#1}}
现在我可以在我的文档中说这样的内容:\inline{my_file.cpp}
我将不胜感激任何帮助!
谢谢
编辑:最小工作示例
\documentclass[a4paper, 12pt]{book}
\usepackage[utf8x]{inputenc} % omogoča uporabo slovenskih črk kodiranih v formatu UTF-8
\usepackage[slovene,english]{babel} % naloži, med drugim, slovenske delilne vzorce
\usepackage[pdftex]{graphicx} % omogoča vlaganje slik različnih formatov
\usepackage{fancyhdr} % poskrbi, na primer, za glave strani
\usepackage{amssymb} % dodatni simboli
\usepackage{amsmath} % eqref, npr.
\usepackage{svg} % for svg pic
%\usepackage{hyperxmp}
\usepackage[pdftex, colorlinks=true,
citecolor=black, filecolor=black,
linkcolor=black, urlcolor=black,
pagebackref=false,
pdfproducer={LaTeX}, pdfcreator={LaTeX}, hidelinks]{hyperref}
\usepackage{courier}
\usepackage{hyperref}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% postavitev strani
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\addtolength{\marginparwidth}{-20pt} % robovi za tisk
\addtolength{\oddsidemargin}{40pt}
\addtolength{\evensidemargin}{-40pt}
\renewcommand{\baselinestretch}{1.3} % ustrezen razmik med vrsticami
\setlength{\headheight}{15pt} % potreben prostor na vrhu
\renewcommand{\chaptermark}[1]%
{\markboth{\MakeUppercase{\thechapter.\ #1}}{}} \renewcommand{\sectionmark}[1]%
{\markright{\MakeUppercase{\thesection.\ #1}}} \renewcommand{\headrulewidth}{0.5pt} \renewcommand{\footrulewidth}{0pt}
\fancyhf{}
\fancyhead[LE,RO]{\sl \thepage} \fancyhead[LO]{\sl \rightmark} \fancyhead[RE]{\sl \leftmark}
\newcommand{\BibTeX}{{\sc Bib}\TeX}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% naslovi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\autfont}{\Large}
\newcommand{\titfont}{\LARGE\bf}
\newcommand{\clearemptydoublepage}{\newpage{\pagestyle{empty}\cleardoublepage}}
\setcounter{tocdepth}{1} % globina kazala
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \convertDate converts D:20080419103507+02'00' to 2008-04-19T10:35:07+02:00
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\convertDate{%
\getYear
}
{\catcode`\D=12
\gdef\getYear D:#1#2#3#4{\edef\xYear{#1#2#3#4}\getMonth}
}
\def\getMonth#1#2{\edef\xMonth{#1#2}\getDay}
\def\getDay#1#2{\edef\xDay{#1#2}\getHour}
\def\getHour#1#2{\edef\xHour{#1#2}\getMin}
\def\getMin#1#2{\edef\xMin{#1#2}\getSec}
\def\getSec#1#2{\edef\xSec{#1#2}\getTZh}
\def\getTZh +#1#2{\edef\xTZh{#1#2}\getTZm}
\def\getTZm '#1#2'{%
\edef\xTZm{#1#2}%
\edef\convDate{\xYear-\xMonth-\xDay T\xHour:\xMin:\xSec+\xTZh:\xTZm}%
}
\expandafter\convertDate\pdfcreationdate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% get pdftex version string
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcount\countA
\countA=\pdftexversion
\advance \countA by -100
\def\pdftexVersionStr{pdfTeX-1.\the\countA.\pdftexrevision}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% for source code
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{listings}
\usepackage{color}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\lstset{frame=tb,
language=C++,
aboveskip=3mm,
belowskip=3mm,
showstringspaces=false,
columns=flexible,
basicstyle={\footnotesize\ttfamily},
numbers=none,
numberstyle=\tiny\color{gray},
keywordstyle=\color{blue},
commentstyle=\color{dkgreen},
stringstyle=\color{mauve},
breaklines=true,
breakatwhitespace=true,
tabsize=4
}
\renewcommand{\lstlistingname}{Izsek kode}% Listing -> Izsek kode
\renewcommand{\lstlistlistingname}{Izseki kod}% List of Listings -> Izseki kod
\newcommand{\shellcmd}[1]{\\\indent\indent\texttt{\footnotesize\# #1}\\}
\def\inline#1{\lstinline[breaklines=true, basicstyle=\ttfamily]{#1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\selectlanguage{slovene}
\frontmatter
\setcounter{page}{1} %
\renewcommand{\thepage}{} % preprecimo težave s številkami strani v kazalu
Sedaj moramo narediti \inline{configure.ac} skripto. To storimo z ukazom \inline{autoscan}. To ukaz nam bo ustvaril dve datoteki in sicer \inline{configure.scan} in \inline{autoscan.log}. Datoteko \inline{configure.scan} moramo preimenovati v \inline{configure.ac}. Vse to naredimo z naslednjim ukazom \shellcmd{autoscan \&\& mv configure.scan configure.ac}
Sedaj, ko imamo datoteko \inline{configure.ac} jo moramo še popraviti. Popravimo sledeče vrstice:
Vrstico \inline{AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])} moramo spremeniti, tako da bo polje \inline{FULL-PACKAGE-NAME} ime našega programa, torej \inline{Ugani}, spremenimo polje \inline{VERSION} v verzijo našega programa, torej \inline{1.0} in spremenimo še polje \inline{BUG-REPORT-ADDRESS} v naš email naslov. V mojem primeru bo to \inline{[email protected]}. Prav tako moramo zakomentirati vrstico \inline{AC_CONFIG_HEADERS([config.h])} saj nismo ustvarili nobene konfiguracijske datoteke \cite{conf_headers}. Prav tako moramo preveriti ali obstaja ukaz \inline{AC_CONFIG_FILES([Makefile])} v naši datoteki \inline{configure.ac}. V primeru da ne obstaja, ga moramo dodati. Ta ukaz pove \inline{autoconf} orodju, kaj so izhodne datoteke \cite{creating_conf_files}. V našem primeru je izhodna datoteka \inline{Makefile}. Prav tako moramo dodati ukaz \inline{AM_INIT_AUTOMAKE}. Vsebina datoteke bi sedaj morala biti sledeča:
\end{document}