{"id":919,"date":"2016-01-02T15:24:55","date_gmt":"2016-01-02T15:24:55","guid":{"rendered":"http:\/\/malemuk.com\/olofee\/?p=919"},"modified":"2016-01-02T15:28:48","modified_gmt":"2016-01-02T15:28:48","slug":"latex-tips","status":"publish","type":"post","link":"https:\/\/malemuk.com\/olofee\/latex-tips\/","title":{"rendered":"LaTeX tips"},"content":{"rendered":"<p>Check also out <a href=\"http:\/\/malemuk.com\/olofee\/?p=943\">BibTeX tips<\/a><\/p>\n<p><strong>Fonts<\/strong><br \/>\nBold<br \/>\n<code>\\textbf{this text written with bold fonts}<\/code><\/p>\n<p>Italic<br \/>\n<code>\\textit{this text is italic}<\/code><\/p>\n<p><strong>Include graphics and images (Windows)<\/strong><br \/>\nIf you use Yap to visualise DVI outputs from LaTeX code, graphics and pictures should be in the EPS format. Many plotting programs, e.g. Matlab, are able to write EPS files.<br \/>\nJPG and PNG files must however be converted to EPS. ImageMagick works well for command line operations on pictures but I haven&#8217;t figured out how to obtain EPS files of reasonable size with it: the size of the EPS output is an order of magnitude greater than that of the JPG input.<br \/>\nFor JPG to EPS conversion I&#8217;m therefore using a program called <a href=\"http:\/\/www.pdflib.com\/download\/free-software\/jpeg2ps\/\">jpeg2ps<\/a> with the following syntax:<br \/>\n<code>jpeg2ps -h -r 600 file.jpg &gt; file.eps<\/code><br \/>\nwhere 600 is the resolution in dpi. This produces an EPS file of approximately double the size of the JPG input.<br \/>\nFor PNG to EPS conversion I&#8217;m using a script\/batch called <a href=\"http:\/\/www.henlich.de\/software\/png2eps\/\">png2eps<\/a> with the following syntax:<br \/>\n<code>png2eps file.png 400 600 file.eps<\/code><br \/>\nwhere the first number is the height in pixels and the second number the resolution in dpi. png2eps requires the following libraries: libtiff, netpbm and zlib. They are available both for Linux and Windows.<br \/>\nApparently it is possible to tell LaTeX to automatically convert JPG files to EPS using jpeg2ps, but I haven&#8217;t managed to get it to work. It also seems possible to include JPG and PNG files directly by using the PGF package but I haven&#8217;t managed to get it to work (&#8220;no BoundingBox&#8221; error).<\/p>\n<p><strong>Include graphics and images (Linux)<\/strong><br \/>\nsam2p works both with jpg and png, provided you have the right libraries installed.<br \/>\n<code>sam2p file.jpg file.eps<\/code><br \/>\nUnfortunately converted sketches are aliased. Another problem is that sam2p does not handle partial transparency, which is something I tend to use when I draw png sketches. Therefore I ended up using png2eps for converting png files to eps.<\/p>\n<p><strong>Output to PDF<\/strong><br \/>\nYou can convert dvi to pdf with dvipdfm:<br \/>\n<code>dvipdfm file.dvi<\/code><\/p>\n<p><strong>Norwegian alphabet (\u00e6, \u00f8, \u00e5)<\/strong><br \/>\nIf you want to write your TeX-file with the Norwegian alphabet, include the following line<br \/>\n<code>\\usepackage[latin1]{inputenx}<\/code><br \/>\nAs far as I understand, the latin1 encoding works for all European languages. Note that the tex file must be encoded the same way. In Emacs, for example, this means loading the Latin-1 language environment. Add the following line to the .emacs file:<br \/>\n<code>(set-language-environment \"Latin-1\")<\/code><br \/>\nFinally, if you&#8217;re writing in another language, you probably want the hyphenation and section names (e.g. &#8220;Chapter&#8221;) to follow this language&#8217;s rules. Use the babel package:<br \/>\n<code>\\usepackage[norsk]{babel}<\/code><\/p>\n<p><strong>Rotate figures and captions<\/strong><br \/>\n<code>\\usepackage{rotating}<\/code><br \/>\nReplace<br \/>\n<code>\\begin{figure}, \\end{figure}<\/code><br \/>\nwith<br \/>\n<code>\\begin{sidewaysfigure}, \\end{sidewaysfigure}<\/code><br \/>\nRemember to replace &#8221;width&#8221; with &#8221;height&#8221; (or the other way around) in the options of the <code>\\includegraphics<\/code> tag.<br \/>\nIn a twoside (<code>\\documentclass[twoside]{...}<\/code>) document, the rotation depends on the page side.<br \/>\nIt is also possible to rotate tables by using<br \/>\n<code>\\begin{sidewaystable}, \\end{sidewaystable}<\/code><\/p>\n<p><strong>Headings<\/strong><br \/>\nHeadings are included with<br \/>\n<code>\\pagestyle{headings}<\/code><br \/>\nThis way, chapter, section, &#8230; titles are written at the pages top.<br \/>\nSome titles may be too long for the page width. One possibility is to include a short version in brackets when declaring the corresponding section:<br \/>\n<code>\\chapter[Short title]{This is a very long title}<\/code><br \/>\nThe short title is also what will appear in the table of contents. The same syntax may be used with the <code>\\caption<\/code> tag to write a shorter caption for the list of figures \/ tables.<\/p>\n<p><strong>Add References to the table of contents<\/strong><br \/>\nUnless you write the following, there will be no References \/ Bibliography entry in the table of contents:<br \/>\n<code>\\addcontentsline{toc}{chapter}{Bibliography}<\/code><br \/>\nYou may want to write similar lines for other numberless parts (e.g. Nomenclature)<\/p>\n<p><strong>Margins<\/strong><br \/>\nUse vmargin package.<br \/>\n<code>\\setmargrb{30mm}{30mm}{30mm}{35mm}<br \/>\n% left margin, top margin, right margin, bottom margin<\/code><br \/>\nFor small margins:<br \/>\n<code>\\usepackage{fullpage}<\/code><\/p>\n<p><strong>List of figures \/ tables layout<\/strong><br \/>\nThe &#8220;report&#8221; template, which I&#8217;ve been using, sets the size of the space between the figure \/ table number in the corresponding list to 2.3em. That is narrow if you have figures numbered N.xx, let alone N.xxx. You may widen the space by adding the following lines somewhere before the \\listoffigures command:<br \/>\n<code>\\makeatletter<br \/>\n\\renewcommand*\\l@figure{\\@dottedtocline{1}{1.5em}{3.3em}}<br \/>\n\\makeatother<\/code><br \/>\nThe <code>\\makeatletter ... \\makeatother<\/code> command is necessary because the renewed command&#8212;<code>\\l@figure<\/code>&#8212;contains an @.<br \/>\nIn the example above the space is set to 3.3em.<\/p>\n<p><strong>Non-breaking hyphen and minus sign<\/strong><br \/>\nFrom what I understand, non-breaking hyphens are written like this:<br \/>\n<code>\\mbox{-}<\/code><br \/>\nand non-breaking minus signs like this:<br \/>\n<code>\\mbox{--}<\/code><\/p>\n<p><strong>Inline equations<\/strong><br \/>\nInline equations are put between $-signs:<br \/>\n<code>$x = 5$<\/code> is an inline equation<br \/>\nAn inline equation requires more than one line of vertical space, e.g. with fractions will look bad unless you write:<br \/>\n<code>\\displaystyle<\/code><br \/>\nin the beginning of the equation.<\/p>\n<p><strong>Indentation of equations<\/strong><br \/>\nBy default, equations are horizontally centered. In order to align equations to the left of the page, instead, add the &#8216;fleqn&#8217; option to the document class:<br \/>\n<code>\\documentclass[fleqn]{article}<\/code><br \/>\nIf you want to indent equations from the left, you must also specify the value of the &#8216;mathindent&#8217; variable:<br \/>\n<code>\\setlength{\\mathindent}{1cm}<\/code><\/p>\n<p><strong>Vertical space<\/strong><br \/>\n<code>\\vspace{2cm}<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Check also out BibTeX tips Fonts Bold \\textbf{this text written with bold fonts} Italic \\textit{this text is italic} Include graphics and images (Windows) If you use Yap to visualise DVI outputs from LaTeX code, graphics and pictures should be in the EPS format. Many plotting programs, e.g. Matlab, are able to write EPS files. JPG [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"class_list":["post-919","post","type-post","status-publish","format-standard","hentry","category-computer-stuff"],"jetpack-related-posts":[{"id":910,"url":"https:\/\/malemuk.com\/olofee\/emacs-tips\/","url_meta":{"origin":919,"position":0},"title":"Emacs tips","date":"December 31, 2015","format":false,"excerpt":"Essential shortcuts M-: META key (ALT on most keyboards) C-: CONTROL key C-x C-f : open file C-x b : switch to buffer C-x k : kill buffer C-s : search text forward C-r : search text backward C-+ \/ C-- : Zoom in\/out C-space: mark set (start of the\u2026","rel":"nofollow","context":"In \"Computer stuff\"","img":{"src":"","width":0,"height":0},"classes":[]},{"id":886,"url":"https:\/\/malemuk.com\/olofee\/coastal-sea-ice-action-on-a-breakwater-in-a-microtidal-inlet-in-svalbard-phd\/","url_meta":{"origin":919,"position":1},"title":"Coastal-sea-ice action on a breakwater in a microtidal inlet in Svalbard (PhD)","date":"December 31, 2015","format":false,"excerpt":"PhD Thesis (PDF) Abstract Preface LaTeX source code of the thesis Writing statistics Defence Trial lecture Defence video Defence slideshow Defence slideshow with notes Questions from the opponents Articles 19th IAHR International Symposium on Ice (2008) Caline, F. and Barrault, S., 2008, Transmission of level ice stresses to the ice\u2026","rel":"nofollow","context":"In \"PhD\"","img":{"src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/malemuk.com\/olofee\/wp-json\/wp\/v2\/posts\/919","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/malemuk.com\/olofee\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/malemuk.com\/olofee\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/malemuk.com\/olofee\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/malemuk.com\/olofee\/wp-json\/wp\/v2\/comments?post=919"}],"version-history":[{"count":3,"href":"https:\/\/malemuk.com\/olofee\/wp-json\/wp\/v2\/posts\/919\/revisions"}],"predecessor-version":[{"id":948,"href":"https:\/\/malemuk.com\/olofee\/wp-json\/wp\/v2\/posts\/919\/revisions\/948"}],"wp:attachment":[{"href":"https:\/\/malemuk.com\/olofee\/wp-json\/wp\/v2\/media?parent=919"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/malemuk.com\/olofee\/wp-json\/wp\/v2\/categories?post=919"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/malemuk.com\/olofee\/wp-json\/wp\/v2\/tags?post=919"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}