Advertisement
Guest User

Algorithm Floats

a guest
Feb 17th, 2011
491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Latex 4.44 KB | None | 0 0
  1. #LyX 1.6.7 created this file. For more info see http://www.lyx.org/
  2. \lyxformat 345
  3. \begin_document
  4. \begin_header
  5. \textclass scrbook
  6. \begin_preamble
  7. \usepackage{algorithm}
  8. \usepackage{booktabs}
  9. \usepackage{caption}
  10. \usepackage{float}
  11. \usepackage{graphicx}
  12. \usepackage[T1]{fontenc}
  13. \usepackage[automark,nouppercase]{scrpage2}
  14. \usepackage[dvipsnames,svgnames,x11names,table]{xcolor}
  15. \usepackage{tikz}
  16. \usetikzlibrary{backgrounds,shadows,shapes,snakes}
  17. \usepackage{pst-grad}
  18. \usepackage{hyperref}
  19.  
  20. \definecolor{sourcecolour}{HTML}{A6BFF2}
  21.  
  22. % Use a hyphen for captions, and make links give a bit of space.
  23. \DeclareCaptionFormat{algorithm}{\vspace{-1ex}\colorbox[HTML]{A6BFF2}{%
  24.   \parbox[c][1.75em][c]{\textwidth}{\hspace{0.25em}#1#2#3}}}
  25. \captionsetup{hypcapspace=0.5\baselineskip}
  26. \captionsetup{labelfont=bf,labelsep=endash}
  27. \captionsetup[ruled]{labelfont=bf,labelsep=endash}
  28. \captionsetup[algorithm]{format=algorithm}
  29.  
  30. % Change algorithm to "Listing".
  31. \floatname{algorithm}{Listing}
  32. \newcommand{\algorithmname}{Listing}
  33.  
  34. % Remove extra whitespace so that colour fills the table header.
  35. \renewcommand{\toprule}{\specialrule{\heavyrulewidth}{\abovetopsep}{0pt}}
  36. \renewcommand{\midrule}{\specialrule{\lightrulewidth}{0pt}{\belowrulesep}}
  37. \renewcommand{\bottomrule}{\specialrule{\lightrulewidth}{0pt}{\belowrulesep}}
  38.  
  39. % Allow figures to be placed near the top of the page.
  40. \renewcommand{\topfraction}{0.85}
  41. \renewcommand{\textfraction}{0.1}
  42. \renewcommand{\floatpagefraction}{0.75}
  43.  
  44. % Determine if the image is too wide for the page.
  45. \makeatletter
  46. \def\ScaleIfNeeded{%
  47.   \ifdim\Gin@nat@width>\linewidth
  48.     \linewidth
  49.   \else
  50.     \Gin@nat@width
  51.   \fi
  52. }
  53. \makeatother
  54.  
  55. % Resize figures that are too wide for the page.
  56. \let\oldincludegraphics\includegraphics
  57. \renewcommand\includegraphics[2][]{%
  58.   \graphicsformat{%
  59.     \oldincludegraphics[width=\ScaleIfNeeded]{#2}%
  60.   }%
  61. }
  62.  
  63. % Centre graphics within non-Algorithm floats.
  64. \let\graphicsformat\centering
  65.  
  66. % Change the background colour of algorithm boxes.
  67. \let\oldalgorithm\algorithm
  68. \let\endoldalgorithm\endalgorithm
  69. \renewenvironment{algorithm}[1][htbp]{
  70.  \let\graphicsformat\justifiedandcolored
  71.  \oldalgorithm[#1]
  72. }%
  73.   {\endoldalgorithm}
  74.  
  75. % Change the background colour of the algorithm floats.
  76. \def\justifiedandcolored#1{%
  77.   \setlength\fboxrule{0pt}%
  78.   \setlength\fboxsep{0pt}%
  79.   \kern-1.45pt
  80.   \tikz[background rectangle/.style={%
  81.           top color=sourcecolour!60,bottom color=white},
  82.   tight background,
  83.   show background rectangle]
  84.   \node [inner sep=0pt] (0,0) {#1};%
  85.   \par
  86.   \kern-1.5pt
  87. }
  88.  
  89. % Allow plenty of room at the bottom (this will prevent large vertical
  90. % gaps between enumerated items and bulleted lists).
  91. \raggedbottom
  92.  
  93. % Required by LyX...
  94. \makeatletter
  95. \end_preamble
  96. \options twoside,pointlessnumbers,obeyspaces,plainpages=false,pdfpagelabels
  97. \use_default_options false
  98. \language english
  99. \inputencoding utf8
  100. \font_roman lmodern
  101. \font_sans helvet
  102. \font_typewriter courier
  103. \font_default_family default
  104. \font_sc false
  105. \font_osf false
  106. \font_sf_scale 100
  107. \font_tt_scale 100
  108.  
  109. \graphics default
  110. \float_placement H
  111. \paperfontsize default
  112. \spacing single
  113. \use_hyperref true
  114. \pdf_bookmarks true
  115. \pdf_bookmarksnumbered false
  116. \pdf_bookmarksopen false
  117. \pdf_bookmarksopenlevel 1
  118. \pdf_breaklinks false
  119. \pdf_pdfborder false
  120. \pdf_colorlinks false
  121. \pdf_backref false
  122. \pdf_pdfusetitle true
  123. \papersize letterpaper
  124. \use_geometry false
  125. \use_amsmath 2
  126. \use_esint 1
  127. \cite_engine basic
  128. \use_bibtopic false
  129. \paperorientation portrait
  130. \secnumdepth 3
  131. \tocdepth 3
  132. \paragraph_separation indent
  133. \defskip medskip
  134. \quotes_language english
  135. \papercolumns 1
  136. \papersides 1
  137. \paperpagestyle default
  138. \bullet 0 5 11 -1
  139. \bullet 1 5 24 -1
  140. \bullet 2 0 0 -1
  141. \tracking_changes false
  142. \output_changes false
  143. \author ""
  144. \author ""
  145. \end_header
  146.  
  147. \begin_body
  148.  
  149. \begin_layout Chapter
  150. Chapter
  151. \end_layout
  152.  
  153. \begin_layout Standard
  154. \begin_inset Float algorithm
  155. wide false
  156. sideways false
  157. status collapsed
  158.  
  159. \begin_layout Plain Layout
  160. \begin_inset Graphics
  161.         filename source/sql/query-formatted.pgsql.png
  162.         display false
  163.  
  164. \end_inset
  165.  
  166.  
  167. \end_layout
  168.  
  169. \begin_layout Plain Layout
  170. \begin_inset Caption
  171.  
  172. \begin_layout Plain Layout
  173. \begin_inset CommandInset label
  174. LatexCommand label
  175. name "alg:Query-with-Formatting"
  176.  
  177. \end_inset
  178.  
  179. Query with Formatting (Bad)
  180. \end_layout
  181.  
  182. \end_inset
  183.  
  184.  
  185. \end_layout
  186.  
  187. \end_inset
  188.  
  189.  
  190. \end_layout
  191.  
  192. \end_body
  193. \end_document
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement