0

I have defined new command like this:

def\inline#1{\lstinline[breaklines=true, basicstyle=\ttfamily]{#1}}

Now I can say something like this in my document: \inline{my_file.cpp}

But here is the problem. enter image description here So, problem is that \hbox is overfull.

I would appreciate any help!

Thanks

Edit: Minimal Working Example

\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@gmail.com}. 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}
  • It helps to provide a Minimal Working Example which illustrates the problem. Without it we really can't test anything, just make guesses. From tex.stackexchange.com/questions/10377/… it might be that \ttfamily prohibits line breaking. Alternatives involve things line \raggedright, \sloppy, \hfil or \centerline. – John Kormylo Aug 12 '15 at 18:07
  • @JohnKormylo I've changed my original post (I've provided minimal working example) – golobich Aug 12 '15 at 19:35
  • Using \sloppy seems to work best. It breaks, at least in the few places it needs to break. If you want to add specific break points, look at tex.stackexchange.com/questions/258285/… for example. (BTW, I could not get your creation date thing to work so I just commented it out.) – John Kormylo Aug 13 '15 at 3:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.