Text Formattingkeep indenting for source code with verbatim?

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
albinoblacksheep
Posts: 12
Joined: Fri Mar 05, 2010 7:53 pm

keep indenting for source code with verbatim?

Post by albinoblacksheep »

Hello!

I want to add some source code to my document and keep the indenting for better readability. I saw that one can use \begin{verbatim} \end{verbatim} for doing so, however in my document that doesn't work. Do you have any hints why?

Here is my MWE:

Code: Select all


\documentclass[a4paper,oneside]{scrbook} %add bibtotoc if necessary

\usepackage{hyperref}

\usepackage[ansinew]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel} 

\usepackage{amsmath,amssymb,amsfonts,amstext}

\usepackage{fancyhdr}
\usepackage{color}
\clubpenalty = 10000 %to prevent widows 
\widowpenalty = 10000 %to prevent widows 
\usepackage[left]{eurosym} %for euro € symbol on left side \EUR{20} => € 20
\usepackage{pdflscape}
%\usepackage{lscape} %for rotating page 90° : \newpage
											%\begin{landscape}
											%   Some text here
											%\end{landscape}
											%\newpage	

%\usepackage[pdftex]{graphicx}
\usepackage{graphicx} %to make compilation with LaTeX work
\usepackage{array}

\setlength{\textheight}{225mm}

\tolerance = 9999
\sloppy

\setcounter{secnumdepth}{3} %uncomment this to not display all the subsubsections in the
\setcounter{tocdepth}{3}    %table of contents
 
\begin{document}
	
\setcounter{page}{1}
\chapter{Test for source code}
\begin{verbatim}
function onMouseDown(event:MouseEvent):void
{    
	circle_obj.transform.colorTransform = new ColorTransform(0, 0, 0, 1, 0, 255, 0, 0);
	var jing:badummsound = new badummsound();
	var channel:SoundChannel = jing.play();
	status_txt.text="Bumm";
}
\end{verbatim}

\end{document}

Thank you!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

keep indenting for source code with verbatim?

Post by frabjous »

Your sample code results in indented code for me.
a-crop.png
a-crop.png (6.76 KiB) Viewed 21578 times
Is this not what you expected, or does it look different for you?

If it looks differently for you, try adding \listfiles to the code and reprocessing, and upload the .log file here.
albinoblacksheep
Posts: 12
Joined: Fri Mar 05, 2010 7:53 pm

keep indenting for source code with verbatim?

Post by albinoblacksheep »

No, unfortunately mine is not indented. (how do you add the pdf here?)

this is my log file generated:

Code: Select all

This is pdfTeX, Version 3.1415926-1.40.9 (MiKTeX 2.7) (preloaded format=pdflatex 2010.1.6)  25 MAR 2010 23:05
entering extended mode
**MWE.tex
(MWE.tex
LaTeX2e <2005/12/01>
Babel <v3.8l> and hyphenation patterns for english, dumylang, nohyphenation, ge
rman, ngerman, german-x-2008-06-18, ngerman-x-2008-06-18, french, loaded.
("C:\Programme\MiKTeX 2.7/tex/latex\koma-script\scrbook.cls"
Document Class: scrbook 2009/04/03 v3.03a KOMA-Script document class (book)
("C:\Programme\MiKTeX 2.7/tex/latex\koma-script\scrkbase.sty"
Package: scrkbase 2009/04/03 v3.03a KOMA-Script package (KOMA-Script-dependent 
basics and keyval usage)

("C:\Programme\MiKTeX 2.7/tex/latex\koma-script\scrbase.sty"
Package: scrbase 2009/04/03 v3.03a KOMA-Script package (KOMA-Script-independent
 basics and keyval usage)

("C:\Programme\MiKTeX 2.7/tex/latex\graphics\keyval.sty"
Package: keyval 1999/03/16 v1.13 key=value parser (DPC)
\KV@toks@=\toks14
)
("C:\Programme\MiKTeX 2.7/tex/latex\koma-script\scrlfile.sty"
Package: scrlfile 2009/03/25 v3.03 KOMA-Script package (loading files)

Package scrlfile, 2009/03/25 v3.03 KOMA-Script package (loading files)
                  Copyright (C) Markus Kohm

))) ("C:\Programme\MiKTeX 2.7/tex/latex\koma-script\tocbasic.sty"
Package: tocbasic 2009/01/20 v3.02a(package)
)
Package tocbasic Info: omitting babel extension for `toc'
(tocbasic)             because of feature `nobabel' available
(tocbasic)             for `toc' on input line 116.
Package tocbasic Info: omitting babel extension for `lof'
(tocbasic)             because of feature `nobabel' available
(tocbasic)             for `lof' on input line 117.
Package tocbasic Info: omitting babel extension for `lot'
(tocbasic)             because of feature `nobabel' available
(tocbasic)             for `lot' on input line 118.
Class scrbook Info: You've used standard option `oneside'.
(scrbook)           This is correct!
(scrbook)           Internaly I'm using `twoside=false'.
(scrbook)           If you'd like to set the option with \KOMAoptions,
(scrbook)           you'd have to use `twoside=false' there
(scrbook)           instead of `oneside', too.
Class scrbook Info: File `scrsize11pt.clo' used instead of
(scrbook)           file `scrsize11.clo' to setup font sizes on input line 1267
.

("C:\Programme\MiKTeX 2.7/tex/latex\koma-script\scrsize11pt.clo"
File: scrsize11pt.clo 2009/04/03 v3.03a KOMA-Script font size class option (11p
t)
)
("C:\Programme\MiKTeX 2.7/tex/latex\koma-script\typearea.sty"
Package: typearea 2009/04/03 v3.03a KOMA-Script package (type area)

Package typearea, 2009/04/03 v3.03a KOMA-Script package (type area)
                  Copyright (C) Frank Neukam, 1992-1994
                  Copyright (C) Markus Kohm, 1994-

\ta@bcor=\skip41
\ta@div=\count79
Package typearea Info: You've used standard option `a4paper'.
(typearea)             This is correct!
(typearea)             Internaly I'm using `paper=a4'.
(typearea)             If you'd like to set the option with \KOMAoptions,
(typearea)             you'd have to use `paper=a4' there
(typearea)             instead of `a4paper', too.
Package typearea Info: You've used standard option `oneside'.
(typearea)             This is correct!
(typearea)             Internaly I'm using `twoside=false'.
(typearea)             If you'd like to set the option with \KOMAoptions,
(typearea)             you'd have to use `twoside=false' there
(typearea)             instead of `oneside', too.
\ta@hblk=\skip42
\ta@vblk=\skip43
\ta@temp=\skip44
Package typearea Info: These are the values describing the layout:
(typearea)             DIV  = 10
(typearea)             BCOR = 0.0pt
(typearea)             \paperwidth      = 597.50793pt
(typearea)              \textwidth      = 418.25555pt
(typearea)              DIV departure   = -6%
(typearea)              \evensidemargin = 17.3562pt
(typearea)              \oddsidemargin  = 17.3562pt
(typearea)             \paperheight     = 845.04694pt
(typearea)              \textheight     = 595.80026pt
(typearea)              \topmargin      = -25.16531pt
(typearea)              \headheight     = 17.0pt
(typearea)              \headsep        = 20.40001pt
(typearea)              \topskip        = 11.0pt
(typearea)              \footskip       = 47.60002pt
(typearea)              \baselineskip   = 13.6pt
(typearea)              on input line 1110.
)
\c@part=\count80
\c@chapter=\count81
\c@section=\count82
\c@subsection=\count83
\c@subsubsection=\count84
\c@paragraph=\count85
\c@subparagraph=\count86
\abovecaptionskip=\skip45
\belowcaptionskip=\skip46
\c@pti@nb@sid@b@x=\box26
\c@figure=\count87
\c@table=\count88
\bibindent=\dimen102
) ("C:\Programme\MiKTeX 2.7/tex/latex\hyperref\hyperref.sty"
Package: hyperref 2008/11/18 v6.78m Hypertext links for LaTeX

("C:\Programme\MiKTeX 2.7/tex/generic\oberdiek\ifpdf.sty"
Package: ifpdf 2007/12/12 v1.6 Provides the ifpdf switch (HO)
Package ifpdf Info: pdfTeX in pdf mode detected.
)
("C:\Programme\MiKTeX 2.7/tex/generic\oberdiek\ifvtex.sty"
Package: ifvtex 2008/11/04 v1.4 Switches for detecting VTeX and its modes (HO)
Package ifvtex Info: VTeX not detected.
)
("C:\Programme\MiKTeX 2.7/tex/generic\ifxetex\ifxetex.sty"
Package: ifxetex 2008/09/18 v0.4 Provides ifxetex conditional
)
("C:\Programme\MiKTeX 2.7/tex/latex\oberdiek\hycolor.sty"
Package: hycolor 2008/09/08 v1.4 Code for color options of hyperref/bookmark (H
O)

("C:\Programme\MiKTeX 2.7/tex/latex\oberdiek\xcolor-patch.sty"
Package: xcolor-patch 2008/09/08 xcolor patch
))
\@linkdim=\dimen103
\Hy@linkcounter=\count89
\Hy@pagecounter=\count90

("C:\Programme\MiKTeX 2.7/tex/latex\hyperref\pd1enc.def"
File: pd1enc.def 2008/11/18 v6.78m Hyperref: PDFDocEncoding definition (HO)
)
("C:\Programme\MiKTeX 2.7/tex/generic\oberdiek\etexcmds.sty"
Package: etexcmds 2007/12/12 v1.2 Prefix for e-TeX command names (HO)

("C:\Programme\MiKTeX 2.7/tex/generic\oberdiek\infwarerr.sty"
Package: infwarerr 2007/09/09 v1.2 Providing info/warning/message (HO)
)
Package etexcmds Info: Could not find \expanded.
(etexcmds)             That can mean that you are not using pdfTeX 1.50 or
(etexcmds)             that some package has redefined \expanded.
(etexcmds)             In the latter case, load this package earlier.
)
("C:\Programme\MiKTeX 2.7/tex/latex\00miktex\hyperref.cfg"
File: hyperref.cfg 2002/06/06 v1.2 hyperref configuration of TeXLive
)
("C:\Programme\MiKTeX 2.7/tex/latex\oberdiek\kvoptions.sty"
Package: kvoptions 2007/10/18 v3.0 Keyval support for LaTeX options (HO)
)
Package hyperref Info: Hyper figures OFF on input line 2907.
Package hyperref Info: Link nesting OFF on input line 2912.
Package hyperref Info: Hyper index ON on input line 2915.
Package hyperref Info: Plain pages OFF on input line 2922.
Package hyperref Info: Backreferencing OFF on input line 2927.

Implicit mode ON; LaTeX internals redefined
Package hyperref Info: Bookmarks ON on input line 3117.
("C:\Programme\MiKTeX 2.7/tex/latex\ltxmisc\url.sty"
\Urlmuskip=\muskip10
Package: url 2006/04/12  ver 3.3  Verb mode for urls, etc.
)
LaTeX Info: Redefining \url on input line 3351.

("C:\Programme\MiKTeX 2.7/tex/generic\oberdiek\bitset.sty"
Package: bitset 2007/09/28 v1.0 Data type bit set (HO)

("C:\Programme\MiKTeX 2.7/tex/generic\oberdiek\intcalc.sty"
Package: intcalc 2007/09/27 v1.1 Expandable integer calculations (HO)
)
("C:\Programme\MiKTeX 2.7/tex/generic\oberdiek\bigintcalc.sty"
Package: bigintcalc 2007/11/11 v1.1 Expandable big integer calculations (HO)

("C:\Programme\MiKTeX 2.7/tex/generic\oberdiek\pdftexcmds.sty"
Package: pdftexcmds 2007/12/12 v0.3 LuaTeX support for pdfTeX utility functions
 (HO)
Package pdftexcmds Info: LuaTeX not detected on input line 139.
)))
("C:\Programme\MiKTeX 2.7/tex/generic\oberdiek\kvsetkeys.sty"
Package: kvsetkeys 2007/09/29 v1.3 Key value parser with default handler suppor
t (HO)
)
\Fld@menulength=\count91
\Field@Width=\dimen104
\Fld@charsize=\dimen105
\Field@toks=\toks15
Package hyperref Info: Hyper figures OFF on input line 4268.
Package hyperref Info: Link nesting OFF on input line 4273.
Package hyperref Info: Hyper index ON on input line 4276.
Package hyperref Info: backreferencing OFF on input line 4283.
Package hyperref Info: Link coloring OFF on input line 4288.
Package hyperref Info: Link coloring with OCG OFF on input line 4293.
Package hyperref Info: PDF/A mode OFF on input line 4298.

("C:\Programme\MiKTeX 2.7/tex/generic\oberdiek\atbegshi.sty"
Package: atbegshi 2008/07/31 v1.9 At begin shipout hook (HO)
)
\Hy@abspage=\count92
\c@Item=\count93
\c@Hfootnote=\count94
)
*hyperref using default driver hpdftex*
("C:\Programme\MiKTeX 2.7/tex/latex\hyperref\hpdftex.def"
File: hpdftex.def 2008/11/18 v6.78m Hyperref driver for pdfTeX
\Fld@listcount=\count95
)
("C:\Programme\MiKTeX 2.7/tex/latex\base\inputenc.sty"
Package: inputenc 2006/05/05 v1.1b Input encoding file
\inpenc@prehook=\toks16
\inpenc@posthook=\toks17

("C:\Programme\MiKTeX 2.7/tex/latex\base\ansinew.def"
File: ansinew.def 2006/05/05 v1.1b Input encoding file
))
("C:\Programme\MiKTeX 2.7/tex/latex\base\fontenc.sty"
Package: fontenc 2005/09/27 v1.99g Standard LaTeX package

("C:\Programme\MiKTeX 2.7/tex/latex\base\t1enc.def"
File: t1enc.def 2005/09/27 v1.99g Standard LaTeX file
LaTeX Font Info:    Redeclaring font encoding T1 on input line 43.
))
("C:\Programme\MiKTeX 2.7/tex/generic\babel\babel.sty"
Package: babel 2008/07/06 v3.8l The Babel package

*************************************
* Local config file bblopts.cfg used
*
("C:\Programme\MiKTeX 2.7/tex/latex\00miktex\bblopts.cfg"
File: bblopts.cfg 2006/07/31 v1.0 MiKTeX 'babel' configuration
)
("C:\Programme\MiKTeX 2.7/tex/generic\babel\english.ldf"
Language: english 2005/03/30 v3.3o English support from the babel system

("C:\Programme\MiKTeX 2.7/tex/generic\babel\babel.def"
File: babel.def 2008/07/06 v3.8l Babel common definitions
\babel@savecnt=\count96
\U@D=\dimen106
)
\l@canadian = a dialect from \language\l@american 
\l@australian = a dialect from \language\l@british 
\l@newzealand = a dialect from \language\l@british 
))
("C:\Programme\MiKTeX 2.7/tex/latex\amsmath\amsmath.sty"
Package: amsmath 2000/07/18 v2.13 AMS math features
\@mathmargin=\skip47

For additional information on amsmath, use the `?' option.
("C:\Programme\MiKTeX 2.7/tex/latex\amsmath\amstext.sty"
Package: amstext 2000/06/29 v2.01

("C:\Programme\MiKTeX 2.7/tex/latex\amsmath\amsgen.sty"
File: amsgen.sty 1999/11/30 v2.0
\@emptytoks=\toks18
\ex@=\dimen107
))
("C:\Programme\MiKTeX 2.7/tex/latex\amsmath\amsbsy.sty"
Package: amsbsy 1999/11/29 v1.2d
\pmbraise@=\dimen108
)
("C:\Programme\MiKTeX 2.7/tex/latex\amsmath\amsopn.sty"
Package: amsopn 1999/12/14 v2.01 operator names
)
\inf@bad=\count97
LaTeX Info: Redefining \frac on input line 211.
\uproot@=\count98
\leftroot@=\count99
LaTeX Info: Redefining \overline on input line 307.
\classnum@=\count100
\DOTSCASE@=\count101
LaTeX Info: Redefining \ldots on input line 379.
LaTeX Info: Redefining \dots on input line 382.
LaTeX Info: Redefining \cdots on input line 467.
\Mathstrutbox@=\box27
\strutbox@=\box28
\big@size=\dimen109
LaTeX Font Info:    Redeclaring font encoding OML on input line 567.
LaTeX Font Info:    Redeclaring font encoding OMS on input line 568.
\macc@depth=\count102
\c@MaxMatrixCols=\count103
\dotsspace@=\muskip11
\c@parentequation=\count104
\dspbrk@lvl=\count105
\tag@help=\toks19
\row@=\count106
\column@=\count107
\maxfields@=\count108
\andhelp@=\toks20
\eqnshift@=\dimen110
\alignsep@=\dimen111
\tagshift@=\dimen112
\tagwidth@=\dimen113
\totwidth@=\dimen114
\lineht@=\dimen115
\@envbody=\toks21
\multlinegap=\skip48
\multlinetaggap=\skip49
\mathdisplay@stack=\toks22
LaTeX Info: Redefining \[ on input line 2666.
LaTeX Info: Redefining \] on input line 2667.
)
("C:\Programme\MiKTeX 2.7/tex/latex\amsfonts\amssymb.sty"
Package: amssymb 2002/01/22 v2.2d

("C:\Programme\MiKTeX 2.7/tex/latex\amsfonts\amsfonts.sty"
Package: amsfonts 2001/10/25 v2.2f
\symAMSa=\mathgroup4
\symAMSb=\mathgroup5
LaTeX Font Info:    Overwriting math alphabet `\mathfrak' in version `bold'
(Font)                  U/euf/m/n --> U/euf/b/n on input line 132.
))
("C:\Programme\MiKTeX 2.7/tex/latex\fancyhdr\fancyhdr.sty"
\fancy@headwidth=\skip50
\f@ncyO@elh=\skip51
\f@ncyO@erh=\skip52
\f@ncyO@olh=\skip53
\f@ncyO@orh=\skip54
\f@ncyO@elf=\skip55
\f@ncyO@erf=\skip56
\f@ncyO@olf=\skip57
\f@ncyO@orf=\skip58
)
("C:\Programme\MiKTeX 2.7/tex/latex\graphics\color.sty"
Package: color 2005/11/14 v1.0j Standard LaTeX Color (DPC)

("C:\Programme\MiKTeX 2.7/tex/latex\00miktex\color.cfg"
File: color.cfg 2007/01/18 v1.5 color configuration of teTeX/TeXLive
)
Package color Info: Driver file: pdftex.def on input line 130.

("C:\Programme\MiKTeX 2.7/tex/latex\pdftex-def\pdftex.def"
File: pdftex.def 2008/09/08 v0.04l Graphics/color for pdfTeX
\Gread@gobject=\count109
))
("C:\Programme\MiKTeX 2.7/tex/latex\eurosym\eurosym.sty"
Package: eurosym 1998/08/06 v1.1 European currency symbol ``Euro''
\@eurobox=\box29
)
("C:\Programme\MiKTeX 2.7/tex/latex\oberdiek\pdflscape.sty"
Package: pdflscape 2008/08/11 v0.10 Landscape pages in PDF (HO)

("C:\Programme\MiKTeX 2.7/tex/latex\graphics\lscape.sty"
Package: lscape 2000/10/22 v3.01 Landscape Pages (DPC)

("C:\Programme\MiKTeX 2.7/tex/latex\graphics\graphics.sty"
Package: graphics 2006/02/20 v1.0o Standard LaTeX Graphics (DPC,SPQR)

("C:\Programme\MiKTeX 2.7/tex/latex\graphics\trig.sty"
Package: trig 1999/03/16 v1.09 sin cos tan (DPC)
)
("C:\Programme\MiKTeX 2.7/tex/latex\00miktex\graphics.cfg"
File: graphics.cfg 2007/01/18 v1.5 graphics configuration of teTeX/TeXLive
)
Package graphics Info: Driver file: pdftex.def on input line 90.
))
Package pdflscape Info: Auto-detected driver: pdftex on input line 75.
)
("C:\Programme\MiKTeX 2.7/tex/latex\graphics\graphicx.sty"
Package: graphicx 1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
\Gin@req@height=\dimen116
\Gin@req@width=\dimen117
)
("C:\Programme\MiKTeX 2.7/tex/latex\tools\array.sty"
Package: array 2005/08/23 v2.4b Tabular extension package (FMi)
\col@sep=\dimen118
\extrarowheight=\dimen119
\NC@list=\toks23
\extratabsurround=\skip59
\backup@length=\skip60
) (MWE.aux)
LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 37.
LaTeX Font Info:    ... okay on input line 37.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 37.
LaTeX Font Info:    ... okay on input line 37.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 37.
LaTeX Font Info:    ... okay on input line 37.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 37.
LaTeX Font Info:    ... okay on input line 37.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 37.
LaTeX Font Info:    ... okay on input line 37.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 37.
LaTeX Font Info:    ... okay on input line 37.
LaTeX Font Info:    Checking defaults for PD1/pdf/m/n on input line 37.
LaTeX Font Info:    ... okay on input line 37.
Package hyperref Info: Link coloring OFF on input line 37.

("C:\Programme\MiKTeX 2.7/tex/latex\hyperref\nameref.sty"
Package: nameref 2007/05/29 v2.31 Cross-referencing by name of section

("C:\Programme\MiKTeX 2.7/tex/latex\oberdiek\refcount.sty"
Package: refcount 2008/08/11 v3.1 Data extraction from references (HO)
)
\c@section@level=\count110
)
LaTeX Info: Redefining \ref on input line 37.
LaTeX Info: Redefining \pageref on input line 37.
 (MWE.out) (MWE.out)
\@outlinefile=\write3
\AtBeginShipoutBox=\box30
 ("C:\Programme\MiKTeX 2.7/tex\context\base\supp-pdf.tex"
[Loading MPS to PDF converter (version 2006.09.02).]
\scratchcounter=\count111
\scratchdimen=\dimen120
\scratchbox=\box31
\nofMPsegments=\count112
\nofMParguments=\count113
\everyMPshowfont=\toks24
\MPscratchCnt=\count114
\MPscratchDim=\dimen121
\MPnumerator=\count115
\everyMPtoPDFconversion=\toks25
)
Chapter 1.
LaTeX Font Info:    Try loading font information for T1+cmss on input line 40.
("C:\Programme\MiKTeX 2.7/tex/latex\base\t1cmss.fd"
File: t1cmss.fd 1999/05/25 v2.5h Standard LaTeX font definitions
)
LaTeX Font Info:    Try loading font information for T1+cmtt on input line 41.

("C:\Programme\MiKTeX 2.7/tex/latex\base\t1cmtt.fd"
File: t1cmtt.fd 1999/05/25 v2.5h Standard LaTeX font definitions
)
Overfull \hbox (51.38924pt too wide) in paragraph at lines 51--51
[]\T1/cmtt/m/n/10.95 circle_obj.transform.colorTransform = new ColorTransform(0
, 0, 0, 1, 0, 255, 0, 0);[] 
 []

[1





pdfTeX warning: pdflatex (file pdftex.map): cannot open font map file
] (MWE.aux)

 *File List*
 scrbook.cls    2009/04/03 v3.03a KOMA-Script document class (book)
scrkbase.sty    2009/04/03 v3.03a KOMA-Script package (KOMA-Script-dependent ba
sics and keyval usage)
 scrbase.sty    2009/04/03 v3.03a KOMA-Script package (KOMA-Script-independent 
basics and keyval usage)
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
scrlfile.sty    2009/03/25 v3.03 KOMA-Script package (loading files)
tocbasic.sty    2009/01/20 v3.02a(package)
scrsize11pt.clo    2009/04/03 v3.03a KOMA-Script font size class option (11pt)
typearea.sty    2009/04/03 v3.03a KOMA-Script package (type area)
hyperref.sty    2008/11/18 v6.78m Hypertext links for LaTeX
   ifpdf.sty    2007/12/12 v1.6 Provides the ifpdf switch (HO)
  ifvtex.sty    2008/11/04 v1.4 Switches for detecting VTeX and its modes (HO)
 ifxetex.sty    2008/09/18 v0.4 Provides ifxetex conditional
 hycolor.sty    2008/09/08 v1.4 Code for color options of hyperref/bookmark (HO
)
xcolor-patch.sty    2008/09/08 xcolor patch
  pd1enc.def    2008/11/18 v6.78m Hyperref: PDFDocEncoding definition (HO)
etexcmds.sty    2007/12/12 v1.2 Prefix for e-TeX command names (HO)
infwarerr.sty    2007/09/09 v1.2 Providing info/warning/message (HO)
hyperref.cfg    2002/06/06 v1.2 hyperref configuration of TeXLive
kvoptions.sty    2007/10/18 v3.0 Keyval support for LaTeX options (HO)
     url.sty    2006/04/12  ver 3.3  Verb mode for urls, etc.
  bitset.sty    2007/09/28 v1.0 Data type bit set (HO)
 intcalc.sty    2007/09/27 v1.1 Expandable integer calculations (HO)
bigintcalc.sty    2007/11/11 v1.1 Expandable big integer calculations (HO)
pdftexcmds.sty    2007/12/12 v0.3 LuaTeX support for pdfTeX utility functions (
HO)
kvsetkeys.sty    2007/09/29 v1.3 Key value parser with default handler support 
(HO)
atbegshi.sty    2008/07/31 v1.9 At begin shipout hook (HO)
 hpdftex.def    2008/11/18 v6.78m Hyperref driver for pdfTeX
inputenc.sty    2006/05/05 v1.1b Input encoding file
 ansinew.def    2006/05/05 v1.1b Input encoding file
 fontenc.sty
   t1enc.def    2005/09/27 v1.99g Standard LaTeX file
   babel.sty    2008/07/06 v3.8l The Babel package
 bblopts.cfg    2006/07/31 v1.0 MiKTeX 'babel' configuration
 english.ldf    2005/03/30 v3.3o English support from the babel system
 amsmath.sty    2000/07/18 v2.13 AMS math features
 amstext.sty    2000/06/29 v2.01
  amsgen.sty    1999/11/30 v2.0
  amsbsy.sty    1999/11/29 v1.2d
  amsopn.sty    1999/12/14 v2.01 operator names
 amssymb.sty    2002/01/22 v2.2d
amsfonts.sty    2001/10/25 v2.2f
fancyhdr.sty    
   color.sty    2005/11/14 v1.0j Standard LaTeX Color (DPC)
   color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
  pdftex.def    2008/09/08 v0.04l Graphics/color for pdfTeX
 eurosym.sty    1998/08/06 v1.1 European currency symbol ``Euro''
pdflscape.sty    2008/08/11 v0.10 Landscape pages in PDF (HO)
  lscape.sty    2000/10/22 v3.01 Landscape Pages (DPC)
graphics.sty    2006/02/20 v1.0o Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2007/01/18 v1.5 graphics configuration of teTeX/TeXLive
graphicx.sty    1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
   array.sty    2005/08/23 v2.4b Tabular extension package (FMi)
 nameref.sty    2007/05/29 v2.31 Cross-referencing by name of section
refcount.sty    2008/08/11 v3.1 Data extraction from references (HO)
     MWE.out
     MWE.out
supp-pdf.tex
  t1cmss.fd    1999/05/25 v2.5h Standard LaTeX font definitions
  t1cmtt.fd    1999/05/25 v2.5h Standard LaTeX font definitions
 ***********

 ) 
Here is how much of TeX's memory you used:
 6787 strings out of 95304
 93363 string characters out of 1183186
 181012 words of memory out of 1500000
 9894 multiletter control sequences out of 110000
 7345 words of font info for 20 fonts, out of 3000000 for 5000
 14 hyphenation exceptions out of 8191
 40i,7n,43p,220b,290s stack positions out of 5000i,500n,10000p,200000b,50000s
 <C:\Dokumente und Einstellungen\Sebi\Lokale Einstellungen\Anwendungsdaten\Mi
KTeX\2.7\fonts\pk\ljfour\jknappen\ec\dpi600\ecrm1095.pk> <C:\Dokumente und Eins
tellungen\Sebi\Lokale Einstellungen\Anwendungsdaten\MiKTeX\2.7\fonts\pk\ljfour\
jknappen\ec\dpi600\ectt1095.pk> <C:\Dokumente und Einstellungen\Sebi\Lokale Ein
stellungen\Anwendungsdaten\MiKTeX\2.7\fonts\pk\ljfour\jknappen\ec\dpi600\ecsx20
74.pk>
Output written on MWE.pdf (1 page, 24224 bytes).
PDF statistics:
 95 PDF objects out of 1000 (max. 8388607)
 3 named destinations out of 1000 (max. 131072)
 21 words of extra memory for PDF output out of 10000 (max. 10000000)


albinoblacksheep
Posts: 12
Joined: Fri Mar 05, 2010 7:53 pm

Re: keep indenting for source code with verbatim?

Post by albinoblacksheep »

Hm... I still can't figure it out. Anyone any ideas? Please help me :)
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

keep indenting for source code with verbatim?

Post by localghost »

You are doing a crucial mistake because you don't describe exactly what is finally going wrong. »It doesn't work« is a trivial statement. frabjous has shown the output as obtained from your code. The next logical step is that you give a counterexample.

Have you seen the warning in the log file? It indicates that pdflatex hasn't unhindered access to some fonts.

Code: Select all

pdfTeX warning: pdflatex (file pdftex.map): cannot open font map file
But I don't think that's a relevant point for a missing indentation.

You can try to rebuild the format files by starting the MiKTeX Options (Admin) from the »Start« menu or reactivate the font map files on the command prompt by executing the following commands (as administrator).

Code: Select all

initexmf -u
initexmf -mkmaps

Best regards
Thorsten
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

keep indenting for source code with verbatim?

Post by frabjous »

[Edit: Just saw Thorsten's advice... try that first...]

Your log file is kind of long and messy, which is probably because you're loading a lot of packages that are probably not part of the problem. I don't have time to go through it right now.

Can you try with something very simple, like this:

Code: Select all

\documentclass{article} 
\listfiles
\begin{document}
    
\begin{verbatim}
function onMouseDown(event:MouseEvent):void
{   
   circle_obj.transform.colorTransform = new ColorTransform(0, 0, 0, 1, 0, 255, 0, 0);
   var jing:badummsound = new badummsound();
   var channel:SoundChannel = jing.play();
   status_txt.text="Bumm";
}
\end{verbatim}
\end{document}
Do you get indenting then?

If so, then keeping changing the above to make it more and more like your previous example, first changing the document class to scrbook and so on, until the problem appears. When it does make note of which package you added that caused the change.

If you don't even get indenting with this minimal example, then post that log file here instead.

(P.S. What I have above is the PDF converted to a PNG image. You can't actually make the PDFs directly visible, though you can upload them as attachments.)
albinoblacksheep
Posts: 12
Joined: Fri Mar 05, 2010 7:53 pm

keep indenting for source code with verbatim?

Post by albinoblacksheep »

Hi!

Thank you both for your answers. I thought by saying "I get no indenting" and afterwards "still does not work" I made myself clear. However if that was not the case I am sorry. I didn't mean to be sloppy.

I tried both that you said. First I executed the command line:
cmd.png
cmd.png (13.1 KiB) Viewed 21545 times
Then I reduced the .tex code: (I tried both document classes "article" and "scrbook", both yielded the same result. I show you the scrbook file here because thats what I want to use finally)

Code: Select all

\documentclass[a4paper,oneside]{scrbook} %add bibtotoc if necessary

\listfiles
\begin{document}

\chapter{this is a test}

some text here

\begin{verbatim}


//function onMouseDown(event:MouseEvent):void
function onMouseDown(event:TouchEvent):void
{    
	circle_obj.transform.colorTransform =
	//arduino.addEventListener(ArduinoEvent
	var jing:badummsound = new badummsound();
	var channel:SoundChannel = jing.play();
	status_txt.text="Bumm";
}

\end{verbatim}
\end{document}
The result I am getting is this:
test.png
test.png (23.89 KiB) Viewed 21545 times
The generated log file is this:

Code: Select all

This is pdfTeX, Version 3.1415926-1.40.9 (MiKTeX 2.7) (preloaded format=pdflatex 2010.3.28)  28 MAR 2010 11:58
entering extended mode
**MWE.tex
(MWE.tex
LaTeX2e <2005/12/01>
Babel <v3.8l> and hyphenation patterns for english, dumylang, nohyphenation, ge
rman, ngerman, german-x-2008-06-18, ngerman-x-2008-06-18, french, loaded.
("C:\Programme\MiKTeX 2.7\tex\latex\koma-script\scrbook.cls"
Document Class: scrbook 2009/04/03 v3.03a KOMA-Script document class (book)
("C:\Programme\MiKTeX 2.7\tex\latex\koma-script\scrkbase.sty"
Package: scrkbase 2009/04/03 v3.03a KOMA-Script package (KOMA-Script-dependent 
basics and keyval usage)

("C:\Programme\MiKTeX 2.7\tex\latex\koma-script\scrbase.sty"
Package: scrbase 2009/04/03 v3.03a KOMA-Script package (KOMA-Script-independent
 basics and keyval usage)

("C:\Programme\MiKTeX 2.7\tex\latex\graphics\keyval.sty"
Package: keyval 1999/03/16 v1.13 key=value parser (DPC)
\KV@toks@=\toks14
)
("C:\Programme\MiKTeX 2.7\tex\latex\koma-script\scrlfile.sty"
Package: scrlfile 2009/03/25 v3.03 KOMA-Script package (loading files)

Package scrlfile, 2009/03/25 v3.03 KOMA-Script package (loading files)
                  Copyright (C) Markus Kohm

))) ("C:\Programme\MiKTeX 2.7\tex\latex\koma-script\tocbasic.sty"
Package: tocbasic 2009/01/20 v3.02a(package)
)
Package tocbasic Info: omitting babel extension for `toc'
(tocbasic)             because of feature `nobabel' available
(tocbasic)             for `toc' on input line 116.
Package tocbasic Info: omitting babel extension for `lof'
(tocbasic)             because of feature `nobabel' available
(tocbasic)             for `lof' on input line 117.
Package tocbasic Info: omitting babel extension for `lot'
(tocbasic)             because of feature `nobabel' available
(tocbasic)             for `lot' on input line 118.
Class scrbook Info: You've used standard option `oneside'.
(scrbook)           This is correct!
(scrbook)           Internaly I'm using `twoside=false'.
(scrbook)           If you'd like to set the option with \KOMAoptions,
(scrbook)           you'd have to use `twoside=false' there
(scrbook)           instead of `oneside', too.
Class scrbook Info: File `scrsize11pt.clo' used instead of
(scrbook)           file `scrsize11.clo' to setup font sizes on input line 1267
.

("C:\Programme\MiKTeX 2.7\tex\latex\koma-script\scrsize11pt.clo"
File: scrsize11pt.clo 2009/04/03 v3.03a KOMA-Script font size class option (11p
t)
)
("C:\Programme\MiKTeX 2.7\tex\latex\koma-script\typearea.sty"
Package: typearea 2009/04/03 v3.03a KOMA-Script package (type area)

Package typearea, 2009/04/03 v3.03a KOMA-Script package (type area)
                  Copyright (C) Frank Neukam, 1992-1994
                  Copyright (C) Markus Kohm, 1994-

\ta@bcor=\skip41
\ta@div=\count79
Package typearea Info: You've used standard option `a4paper'.
(typearea)             This is correct!
(typearea)             Internaly I'm using `paper=a4'.
(typearea)             If you'd like to set the option with \KOMAoptions,
(typearea)             you'd have to use `paper=a4' there
(typearea)             instead of `a4paper', too.
Package typearea Info: You've used standard option `oneside'.
(typearea)             This is correct!
(typearea)             Internaly I'm using `twoside=false'.
(typearea)             If you'd like to set the option with \KOMAoptions,
(typearea)             you'd have to use `twoside=false' there
(typearea)             instead of `oneside', too.
\ta@hblk=\skip42
\ta@vblk=\skip43
\ta@temp=\skip44
Package typearea Info: These are the values describing the layout:
(typearea)             DIV  = 10
(typearea)             BCOR = 0.0pt
(typearea)             \paperwidth      = 597.50793pt
(typearea)              \textwidth      = 418.25555pt
(typearea)              DIV departure   = -6%
(typearea)              \evensidemargin = 17.3562pt
(typearea)              \oddsidemargin  = 17.3562pt
(typearea)             \paperheight     = 845.04694pt
(typearea)              \textheight     = 595.80026pt
(typearea)              \topmargin      = -25.16531pt
(typearea)              \headheight     = 17.0pt
(typearea)              \headsep        = 20.40001pt
(typearea)              \topskip        = 11.0pt
(typearea)              \footskip       = 47.60002pt
(typearea)              \baselineskip   = 13.6pt
(typearea)              on input line 1110.
)
\c@part=\count80
\c@chapter=\count81
\c@section=\count82
\c@subsection=\count83
\c@subsubsection=\count84
\c@paragraph=\count85
\c@subparagraph=\count86
\abovecaptionskip=\skip45
\belowcaptionskip=\skip46
\c@pti@nb@sid@b@x=\box26
\c@figure=\count87
\c@table=\count88
\bibindent=\dimen102
) (MWE.aux)
LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.
LaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 4.
LaTeX Font Info:    ... okay on input line 4.

Chapter 1.
[1



{C:/Dokumente und Einstellungen/Sebi/Lokale Einstellungen/Anwendungsdaten/MiKTe
X/2.7/pdftex/config/pdftex.map}] (MWE.aux)

 *File List*
 scrbook.cls    2009/04/03 v3.03a KOMA-Script document class (book)
scrkbase.sty    2009/04/03 v3.03a KOMA-Script package (KOMA-Script-dependent ba
sics and keyval usage)
 scrbase.sty    2009/04/03 v3.03a KOMA-Script package (KOMA-Script-independent 
basics and keyval usage)
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
scrlfile.sty    2009/03/25 v3.03 KOMA-Script package (loading files)
tocbasic.sty    2009/01/20 v3.02a(package)
scrsize11pt.clo    2009/04/03 v3.03a KOMA-Script font size class option (11pt)
typearea.sty    2009/04/03 v3.03a KOMA-Script package (type area)
 ***********

 ) 
Here is how much of TeX's memory you used:
 1144 strings out of 95304
 16921 string characters out of 1183185
 88701 words of memory out of 1500000
 4407 multiletter control sequences out of 110000
 5001 words of font info for 19 fonts, out of 3000000 for 5000
 14 hyphenation exceptions out of 8191
 36i,6n,43p,217b,148s stack positions out of 5000i,500n,10000p,200000b,50000s
<C:/Programme/MiKTeX 2.7/fonts/type1/bluesky/cm/cmr10.pfb><C:/Programme/MiKTe
X 2.7/fonts/type1/bluesky/cm/cmssbx10.pfb><C:/Programme/MiKTeX 2.7/fonts/type1/
bluesky/cm/cmtt10.pfb>
Output written on MWE.pdf (1 page, 19071 bytes).
PDF statistics:
 18 PDF objects out of 1000 (max. 8388607)
 0 named destinations out of 1000 (max. 131072)
 1 words of extra memory for PDF output out of 10000 (max. 10000000)
The warning has disappeared, however the indenting still doesn't work.
I am using Miktex 2.7 with Texmaker 1.9.1. I am on Windows XP SP3.

I hope this is all you need now, please let me know if I forgot to provide some other important info!

Thank you for your help
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

keep indenting for source code with verbatim?

Post by frabjous »

Here's my .log file from running the same code, where the indentation works fine:

Code: Select all

This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009)
entering extended mode
(./go.tex
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, german-x-2009-06-19, ngerman-x-2009-06-19, ancientgreek, ibycus, ar
abic, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danish, dutc
h, esperanto, estonian, farsi, finnish, french, galician, german, ngerman, mono
greek, greek, hungarian, icelandic, indonesian, interlingua, irish, italian, ku
rmanji, latin, latvian, lithuanian, mongolian, mongolian2a, bokmal, nynorsk, po
lish, portuguese, romanian, russian, sanskrit, serbian, slovak, slovenian, span
ish, swedish, turkish, ukenglish, ukrainian, uppersorbian, welsh, loaded.
(/usr/local/texlive/2009/texmf-dist/tex/latex/koma-script/scrbook.cls
Document Class: scrbook 2010/02/15 v3.05 KOMA-Script document class (book)
(/usr/local/texlive/2009/texmf-dist/tex/latex/koma-script/scrkbase.sty
(/usr/local/texlive/2009/texmf-dist/tex/latex/koma-script/scrbase.sty
(/usr/local/texlive/2009/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2009/texmf-dist/tex/latex/koma-script/scrlfile.sty
Package scrlfile, 2009/03/25 v3.03 KOMA-Script package (loading files)
                  Copyright (C) Markus Kohm

))) (/usr/local/texlive/2009/texmf-dist/tex/latex/koma-script/tocbasic.sty)
(/usr/local/texlive/2009/texmf-dist/tex/latex/koma-script/scrsize11pt.clo)
(/usr/local/texlive/2009/texmf-dist/tex/latex/koma-script/typearea.sty
Package typearea, 2010/02/15 v3.05 KOMA-Script package (type area)
                  Copyright (C) Frank Neukam, 1992-1994
                  Copyright (C) Markus Kohm, 1994-

)) (./go.aux)
Chapter 1.
[1{/home/kck/.texlive2009/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./go.aux)

 *File List*
 scrbook.cls    2010/02/15 v3.05 KOMA-Script document class (book)
scrkbase.sty    2010/02/15 v3.05 KOMA-Script package (KOMA-Script-dependent bas
ics and keyval usage)
 scrbase.sty    2010/02/15 v3.05 KOMA-Script package (KOMA-Script-independent b
asics and keyval usage)
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
scrlfile.sty    2009/03/25 v3.03 KOMA-Script package (loading files)
tocbasic.sty    2010/01/05 v3.04b KOMA-Script package (handling toc-files)
scrsize11pt.clo    2010/02/15 v3.05 KOMA-Script font size class option (11pt)
typearea.sty    2010/02/15 v3.05 KOMA-Script package (type area)
 ***********

 )</usr/local/texlive/2009/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb>
</usr/local/texlive/2009/texmf-dist/fonts/type1/public/amsfonts/cm/cmssbx10.pfb
></usr/local/texlive/2009/texmf-dist/fonts/type1/public/amsfonts/cm/cmtt10.pfb>
Output written on go.pdf (1 page, 37846 bytes).
SyncTeX written on go.synctex.gz
Transcript written on go.log.
As you can see my log is shorter than yours, and I confess I don't really understand what's going on with some of yours. (Perhaps some of the experts here would.) You can also see that I'm using newer versions of some of class and style files, though it's hard to believe that these are an issue either if you get the problem with article.cls too. I guess you could try updating everything, but I don't know whether or not that would help.

What about these steps first:

1. Does it make a difference whether you use spaces or tabs for the indenting?
2. Does it make a difference whether you load packages like verbatim or listings and use to display your code?
albinoblacksheep
Posts: 12
Joined: Fri Mar 05, 2010 7:53 pm

Re: keep indenting for source code with verbatim?

Post by albinoblacksheep »

Hi!

When I use tabs for indenting (which is also the default when I copy-paste the source code) then indenting does not work.
When I manually delete the tabs and replace them with spaces it works!

Adding \usepackage{verbatim} and \usepackage{listings} does not change this behavior.

Well at least now I found a method to make indenting work somehow. Seems like I will have to add a lot of spaces to my thesis...

Perhaps I will try updating the software, but I am not sure that will help.

Thank you all the same!
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

keep indenting for source code with verbatim?

Post by frabjous »

You could try moreverb. It claims to support tabs.

Actually, it doesn't work for me with tabs either otherwise. Apparently these forums were converting the tabs to spaces when you put them in the

Code: Select all

...[ /code] tags.

Frankly, I consider that a bug with the forum software. I also really dislike how it adds extra spaces anyway when you copy and paste from it.

Of course, search and replace should handle the tab>space conversion for you if need be...
Post Reply