14

You aren’t selecting the Fortran-77 dialect in your listing. According to the language-definition manual, the c and C comments were removed for Fortran-90 and later, since otherwise CONTAINS could start a comment. The listing version of Fortran 77 does not define ! comments, which I believe your compiler is making available as an extension to Fortran-77. ...


5

When inputting a file with \InputIfFileExists (basically what is used everywhere across LaTeX, except for a few special cases like the plain syntax \input <file>), it sets the \CurrentFile, uses the hooks file/before and file/before/\CurrentFile, then reads the file in, then uses file/after/\CurrentFile and file/after. The problem with that, is that if ...


4

Your morecomment setting is saying that comments begin with ! and end with c. Do this instead. morecomment=[l]{!} C is already defined as a comment in the fortran77 style so you shouldn't need to declare it. All of this is untested.


2

The pdfTeX has command \pdffakespace to insert a space into the document. This space is invisible, but it is taken into account during text copying. So, my first idea was to insert \pdffakespace after each space at the beginning of lines, but unfortunately, it results in spaces doubling in the copied text (one space comes from \pdffakespace and another is ...


2

If you want to stick with pdflatex, this should work: \documentclass{article} \usepackage{listings} \begin{document} \noindent danish special chars æ ø å \lstset{literate=% {æ}{{\ae}}1 {ø}{{\o}}1 {å}{{\aa}}1 } \begin{lstlisting} danish special chars æ ø å \end{lstlisting} \end{document}


2

Using \showoutput, for instance before \begin{document}, one can see the following material set in vertical mode, around your verbatim text: ...\glue 6.0 plus 2.0 minus 2.0 ...\glue 0.0 ...\glue(\parskip) 0.0 ...\glue(\baselineskip) 1.6556 ...\hbox(8.39996+3.60004)x345.0, glue set 56.99707fil (...) <--- verbatim text here ...\penalty -50 ...\glue 6.0 ...


2

An extended, but revised, version of your MWE. % loeprob.tex SE 578105 \documentclass{article} \usepackage{lipsum} \usepackage{tocloft} \newcommand{\listexamplename}{example} \newlistof{example}{exp}{\listexamplename} \newcommand{\example}[1]{ \refstepcounter{example} %\par\noindent\textbf{Example \theexample. #1} \addcontentsline{exp}{example} {\protect\...


1

The answer is from the comments above with some modification which are: Hilight the #pragma keyword in a C/C++ code New keywords are not highlighted inside a string \documentclass{article} \usepackage{listings} \usepackage{xcolor} \lstset{ language=C, showstringspaces=false, stringstyle={\color{red}}, keywordstyle={\color{blue}}, ...


1

Remove the hbox option from here: \begin{bashcode}[hbox,enhanced,drop shadow]{Installing packages} ^^^^


1

One more solution that works well in both Acrobat Reader and Chrome, but is compatible with pdfTeX only (not XeTeX/LuaTeX): \usepackage{transparent} \makeatletter \def\@xobeysp{\leavevmode\nobreak\texttransparent{0}{\char32}} \makeatother The \texttransparent is used to make ⎵ symbol invisible (actually, in some fonts the slot 32 is mapped onto the real ...


Only top voted, non community-wiki answers of a minimum length are eligible