CSCM10 Research Methodology a Taster of LATEX WYSIWYG
Total Page:16
File Type:pdf, Size:1020Kb
WYSIWYG Systems CSCM10 Research Methodology A Taster of LATEX Anton Setzer • WYSIWYG = \What You See Is What You Get". http://www.cs.swan.ac.uk/∼csetzer/lectures/ • What you type in can be seen directly on the screen. computerScienceProjectResearchMethods/current/index.html • Microsoft Office Word is the main example of a WYSIWYG system. October 22, 2017 CSCM10 Lecture 4, 11/2/16: LATEX 2/ 32 Advantages/Disadvantages of WYSIWYG Systems WYSIWYM • WYSIWYG systems are relatively easy to use. • In WYSIWYG systems typesetting to be done by the user. • Problem: most users are not professional type setters. • WYSIWYM = \What You See Is What You Mean". • In most systems (e.g. Word) you can see only the output, but • Instead of doing the typesetting directly the user says: not the formatting information. • This is a headline. • Difficult to detect that one headline is in 11 pt and another in • This is a section title. 12 pt, or one headline in one font, and another in a slightly • This text is normal text. different font. • This is a mathematical formula • Therefore output is usually inconsistent. • Main examples: TEXand LATEX. • Usually output not of printable quality. • Programming is difficult, definition of macros restricted and difficult. CSCM10 Lecture 4, 11/2/16: LATEX 3/ 32 CSCM10 Lecture 4, 11/2/16: LATEX 4/ 32 Advantages/Disadvantages of WYSIWYM Systems LATEX • Steeper learning curve. • Separation of output from input, therefore what you write needs to be compiled into text. • Can create text in print quality. • TEX developed by Donald Knuth in order to typeset a new • Many publishers print articles typeset in LATEX directly, or after version of his books \The art of Computer Programming". adding their own generic macros. • LATEX (for Lamport-TEX) developed by Laslie Lamport in • User sees all formatting information and can therefore produce order to make a more user friendly version of TEX. very uniform text. • LATEX is essentially a macro package on top of TEX. • Programmable using macros. • Development of macro packages for many purposes. • In LATEX macro packages e.g. for chess, for typesetting proofs, chemical formulas exist. • These slides are typeset in LATEX. CSCM10 Lecture 4, 11/2/16: LATEX 5/ 32 CSCM10 Lecture 4, 11/2/16: LATEX 6/ 32 Use of LATEX for Reports and Dissertation Example • The following shows an example of LATEX code (split into 3 • Reports and dissertations can be written using any text codes) plus the output. processing system. • For ease of presentation after each code piece the final output • Use of LATEX will in many cases give you an advantage (which is only produced after running latex on the whole because of the much higher quality of the output. code) is shown. A • Many lecturers (but not all) use LTEX, especially for scientific • The source for this file is available from the webpage for the publishing. lectures by Anton Setzer for this module or here: • They might help you with LATEX. http://www.cs.swan.ac.uk/∼csetzer/lectures/ computerScienceProjectResearchMethods/current/latex/exampleWikipedia/exampleWikipedia.tex CSCM10 Lecture 4, 11/2/16: LATEX 7/ 32 CSCM10 Lecture 4, 11/2/16: LATEX 8/ 32 Example LATEXOutput ndocumentclass[12pt]farticleg nusepackagefamsmathg ntitlefnLaTeXg nauthorfAnton Setzer nthanksfDept. of Computer Science, Swansea University, Singleton Park, Swansea SA1 4PZ, UK. Email: fntt [email protected]. This article is based on the example in Wikipedia, http://en.wikipedia.org/wiki/LaTeXgg ndatef7 October 2011g nnewcommandfnrolegffrn^foglegg nbeginfdocumentg nmaketitle CSCM10 Lecture 4, 11/2/16: LATEX 9/ 32 CSCM10 Lecture 4, 11/2/16: LATEX 10/ 32 Example (Continued) LATEXOutput nLaTeXfg is a document preparation system for the nTeXfg typesetting program. It offers programmable desktop publishing features and extensive facilities for automating most aspects of typesetting and desktop publishing, including numbering and cross-referencing, tables and figures, page layout, bibliographies, and much more. nLaTeXfg was originally written in 1984 by Leslie Lamport and has become the dominant method for using nTeX; few people write in plain nTeXfg anymore. The current version is nLaTeXe. nLaTeXfg plays an important nrolefg in publishing scientific articles in Science. % This is a comment; it will not be shown % in the final output. CSCM10 Lecture 4, 11/2/16: LATEX 11/ 32 CSCM10 Lecture 4, 11/2/16: LATEX 12/ 32 LATEXOutput Example (Continued) % The following shows a little of the typesetting power % of LaTeX: nbeginfaligng E &= mc^2 nn m &= nfracfm 0gfnsqrtf1-nfracfv^2gfc^2ggg nendfaligng nendfdocumentg CSCM10 Lecture 4, 11/2/16: LATEX 13/ 32 CSCM10 Lecture 4, 11/2/16: LATEX 14/ 32 LATEXOutput LATEXOutput CSCM10 Lecture 4, 11/2/16: LATEX 15/ 32 CSCM10 Lecture 4, 11/2/16: LATEX 16/ 32 Running LATEX More Details csetzer@csltas2:∼> latex exampleWikipedia.tex • ndocumentclass[12pt]farticleg latex exampleWikipedia.tex • Standard Header of a Latex file. 12pt = font size This is pdfTeX, Version 3.1415926-1.40.10 • • article = style (TeX Live 2009/Debian) (Article is suitable for reports. entering extended mode There are lots of other styles. (./exampleWikipedia.tex Style \book" is the simplest style for dissertations. LaTeX2e <2009/09/24> { There are many more fancy ones.) Babel <v3.8l> and hyphenation patterns for english, • nusepackagefamsmathg usenglishmax, dumylang, nohyphenation, farsi, • Loads package amstmath. arabic, croatian, bulgarian, ukrainian, russian, czech, • Rich package for mathematics, here used for command nfrac. slovak, danish, dutch, finnish • Lots of packages are available. ... lots of more output ... • ntitlefnLaTeXg Output written on exampleWikipedia.dvi (1 page, 2364 bytes). • Defines the title. A Transcript written on exampleWikipedia.log. • nLaTeXfg is a macro typesetting LTEX. csetzer@csltas2:∼> xdvi exampleWikipedia.dvi & • nauthorfAnton Setzer • Starts defining the author (note f not closed yet) CSCM10 Lecture 4, 11/2/16: LATEX 17/ 32 CSCM10 Lecture 4, 11/2/16: LATEX 18/ 32 More Details More Details • nthanksfDept. of Computer Science, Swansea University, Singleton Park, • nnewcommandfnrolegffrn^foglegg Swansea SA1 4PZ, UK. • Defines a macro. Email: fntt [email protected]. • From now on nrole will expand to This article is based on the example in frn^fogleg. Wikipedia, • Curly brackets will be used to group text but will not be http://en.wikipedia.org/wiki/LaTeXgg printed. • n^fog typesets ^o • Footnote added to author. • There are macros for defining lots and lots of special symbols. • fntt · · · g type sets this part in type writer font. • http://www.tug.org/tex-archive/info/symbols/comprehensive/ • Second \g" finishes definition of author. • Macros can have parameters as well. ndatef7 October 2011g • Defines the date. CSCM10 Lecture 4, 11/2/16: LATEX 19/ 32 CSCM10 Lecture 4, 11/2/16: LATEX 20/ 32 More Details More Details • nLaTeXfg is a document preparation system for the nTeXfg typesetting program. It offers ··· • nbeginfdocumentg • This is standard text to be typeset. • Start of the content of the document. • Aligning the text done by the system. • nmaketitle • Line breaks in the text create only space between words. • Puts title, author, date at this position. • Double line breaks creates a paragraph • Without this command no title, author, date will occur in the (Equivalently one can use the macro npar). document. • Several blanks, tabs, line breaks are the same as a single space (except for double line breaks). • nTeXfg typesets TEX. CSCM10 Lecture 4, 11/2/16: LATEX 21/ 32 CSCM10 Lecture 4, 11/2/16: LATEX 22/ 32 More Details Example (Continued) • nLaTeXfg plays an important nrolefg in publishing • Here the user defined macro nrolefg typeset as r^oleis used. • nbeginfaligng • fg here makes sure that there is a blank after LATEXand after ··· r^ole. nendfaligng Spaces after a macro are ignored. • Example of an environment. • There are many environments in LAT X. • % This is a comment; it will not be shown E • Everything in a a line after % is a comment CSCM10 Lecture 4, 11/2/16: LATEX 23/ 32 CSCM10 Lecture 4, 11/2/16: LATEX 24/ 32 Example (Continued) Example (Continued) • nbeginfaligng • c^2 ··· & · · · nn • Typesets c2 in mathematical text. ··· & · · · nn • m 0. nendfaligng • Typesets m0 in mathematical text. • Environment align typesets several formulae, which are numbered as (1), (2) consecutively. • nfrac{· · · }{· · · g ··· • Content of an align environment is mathematical text. • Type sets a fraction ··· . • LATEX and TEX have a text mode and a formula mode. • Note that we can nest fractions. • In formula mode different macros (usually for creating • nsqrt{· · · g mathematical text) are used. p • Typesets ···. • In mathematical text all blanks are ignored. • Mathematical text is where the full power of LATEX/TEXis • nendfaligng shown. • End of align environment. Seems to be the easiest system for typesetting formulae. • • nendfdocumentg • nn separates lines in mathematical text (can be used for • End of the document. ordinary text as well). • Text after this will be ignored. • Symbols & mark positions to be aligned. CSCM10 Lecture 4, 11/2/16: LATEX 25/ 32 CSCM10 Lecture 4, 11/2/16: LATEX 26/ 32 LATEX under Windows BibTex • Use any text editor. Recommended: Emacs or XEmacs. • BibTex allows to create your bibliography automatically from • MikTeX is a LATEX compiler for Windows. a BibTex file, in which bibliography entries are listed in a • For viewing dvi files use the included YAP dvi-viewer. database like syntax. • For postscript use GhostScript + GSView. • Publishers and many authors provide BibTex entries for many publication. • See for instance http://www.pinteric.com/miktex.html • Google scholar can be adjusted through settings to provide on how to use LATEX under Windows. BibTeX entries - however there usually need a lot of adjustments. • Other onlinetools avilable e.g. ShareLatex. CSCM10 Lecture 4, 11/2/16: LATEX 27/ 32 CSCM10 Lecture 4, 11/2/16: LATEX 28/ 32 Example BibTeX entry Example BibTeX entry • We wrote fLgafTgafXg, because BibTeX puts by default everything in lowercase in titles, except for the first character.