]> git.lyx.org Git - lyx.git/blob - src/tex2lyx/test/test-insets.tex
Do not swallow math comments in tex2lyx.
[lyx.git] / src / tex2lyx / test / test-insets.tex
1 %% LyX trick_preamble_code_into_believing_that_this_was_created_by_lyx created this file.  For more info, see http://www.lyx.org/.
2 %% Do not edit unless you really know what you are doing.
3 \documentclass[a4paper,12pt]{article}
4 \usepackage[T1]{fontenc}
5 \usepackage[latin9]{inputenc}
6
7 \setlength{\parindent}{3mm}
8 \usepackage{setspace}
9 \onehalfspacing
10
11 \usepackage{amsmath}
12 \usepackage{url}
13 \usepackage{verbatim}
14 \usepackage[numbers]{natbib}
15 \usepackage{nomencl}
16 % the following is useful when we have the old nomencl.sty package
17 \providecommand{\printnomenclature}{\printglossary}
18 \providecommand{\makenomenclature}{\makeglossary}
19 \makenomenclature
20 \usepackage{varioref}
21 \usepackage{prettyref}
22 \usepackage{makeidx}
23 \usepackage{splitidx}
24 \makeindex
25
26 \usepackage{graphicx}
27 \usepackage{longtable}
28 \usepackage{xargs}
29 \usepackage{subscript}
30
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
32 \providecommand{\LyX}{L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\@}
33 \newcommand{\lyxline}[1][1pt]{%
34   \par\noindent%
35   \rule[.5ex]{\linewidth}{#1}\par}
36
37 \newcommand{\lyxarrow}{\leavevmode\,$\triangleright$\,\allowbreak}
38
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
40
41 \def\mycommand{\textquestiondown}
42
43 \begin{document}
44
45 \title{Title}
46
47 \date %stupid stuff
48 {two days ago}
49
50 \maketitle
51
52 \tableofcontents
53 \lstlistoflistings
54
55 \noindent This paragraph is not indented.
56
57 \section{References\index{References}}
58
59 Let's start with simple things: a label~\label{lab:test} and a
60 reference~\ref{lab:test}; note that I have tested ``unbreakable
61 space'' without warning (and worse than that, I just tested english
62 quotes too...).
63
64 Of course there are other kind of references, like page
65 reference~\pageref{lab:test}, but also equation
66 reference~\eqref{lab:test} (from amsmath package), or varioref's
67 equivalents~\vref{lab:test} and~\vpageref{lab:test}, without
68 forgetting pretty references like~\prettyref{lab:test}.
69
70 \section{Cites\index{Cites}}
71
72 Let's start with simple things: a \textbackslash{}cite: \cite[after]{article-crossref}
73 and two \textbackslash{}cites: \cite[after]{whole-set,article-crossref}
74
75 Now the natbib things:
76
77 \textbackslash{}citet: \citet[before][after]{article-crossref} \textbackslash{}citet{*}:
78 \citet*[before][after]{article-crossref} \textbackslash{}Citet: \Citet[before][after]{article-crossref}
79 \textbackslash{}Citet{*}: \Citet*[before][after]{article-crossref}
80
81 \textbackslash{}citep: \citep[before][after]{article-crossref} \textbackslash{}citep{*}:
82 \citep*[before][after]{article-crossref} \textbackslash{}Citep: \Citep[before][after]{article-crossref}
83 \textbackslash{}Citep{*}: \Citep*[before][after]{article-crossref}
84
85 \textbackslash{}citealt: \citealt[before][after]{article-crossref}
86 \textbackslash{}citealt{*}: \citealt*[before][after]{article-crossref}
87 \textbackslash{}Citealt: \Citealt[before][after]{article-crossref}
88 \textbackslash{}Citealt{*}: \Citealt*[before][after]{article-crossref}
89
90 \textbackslash{}citealp: \citealp[before][after]{article-crossref}
91 \textbackslash{}citealp{*}: \citealp*[before][after]{article-crossref}
92 \textbackslash{}Citealp: \Citep[before][after]{article-crossref}
93 \textbackslash{}Citealp{*}: \Citealp*[before][after]{article-crossref}
94
95 \textbackslash{}citeauthor: \citeauthor[before][after]{article-crossref}
96 \textbackslash{}citeauthor{*}: \citeauthor*[before][after]{article-crossref}
97 \textbackslash{}Citeauthor: \Citeauthor[before][after]{article-crossref}
98 \textbackslash{}Citeauthor{*}: \Citeauthor*[before][after]{article-crossref}
99
100 \textbackslash{}citeyear: \citeyear[before][after]{article-crossref}
101
102 \textbackslash{}citeyearpar: \citeyearpar[before][after]{article-crossref} 
103
104 \textbackslash{}nocite: \nocite{article-crossref}
105
106 % Remove duplicate call of \bibliography since LaTeX throws an error.
107 %\bibliographystyle{unsrt}
108 % \bibliography{xampl}
109
110 With \textbackslash{}nocite\{{*}\}:
111 \bibliographystyle{unsrt}
112 \nocite{*}
113 \bibliography{xampl}
114
115 From bug 7306:
116 \citet{gur+04} have demonstrated that authors should not have umlauts
117 in their names. It's OK to use them in the man\"{u}script, though.
118 \begin{thebibliography}{References}
119 \bibitem[{{G\"{u}rkan et~al.}(2004)}]{gur+04} Gürkan, M.~A., Freitag,
120 M., \& Rasio, F.~A. 2004, ApJ, 604, 632\end{thebibliography}
121
122
123 \section{Input files\index{Input files}}
124
125 We can input files too, like this \input{DummyDocument}, or with the include
126 variant \include{DummyDocument} % unfortunately, including the doc twice generates a multiply defined label
127
128 We can also import chess diagrams:
129
130 \loadgame{../../../lib/examples/iecc05}\showboard
131
132 Spreadsheets:
133
134 \def\inputGnumericTable{}\input{../../../lib/examples/longsheet.gnumeric}
135
136 and PDF pages:
137
138 \includepdf[pages=-,angle=22,origin=Bl,width=5cm,height=40mm,keepaspectratio]{../../../lib/examples/beamer-icsi-logo}
139
140 If you prefer verbatim input, you can choose
141 between~\verbatiminput{foo} or~\verbatiminput*{foo}.
142
143
144 \section{URLs and Hyperlinks\index{URL}\nomenclature[www]{URL}{uniform resource locator}}
145
146 An URL: \url{http://www.lyx.org} \nomenclature{URL2}{uniform resource locator}
147
148 link:\href{http://www.test.test}{www.test.test}
149
150 link2:\href{http://www.test.test}{http://www.test.test}
151
152 mail:\href{mailto:www.test.test}{name}
153
154 file:\href{file:www.test.test}{www.test.test}
155
156 ftp:\href{ftp://www.test.test}{ftp://www.test.test}
157
158 ftp2:\href{ftp://www.test.test}{www.test.test}
159
160
161 \section{Lists\index{Lists}}
162
163 \listoffigures
164 \listoftables
165
166
167 \section{Listings}
168
169 Inline: \lstinline[language={C++}]!int a=5;!\\
170 Float:
171
172 \begin{lstlisting}[caption={Example Listing float},label={lst:Example-Listing},language=Python]
173 # Example listing float
174 def func(param):
175     'this is a python function'
176     pass
177 \end{lstlisting}
178
179 Here is an example listing with left line numbering, step ``3'',
180 language ``Python'', options ``Extended character table'' and
181 ``Space~as~symbol'', range lines 3\,-\,8:
182
183 \begin{lstlisting}[extendedchars=true,firstline=3,language=Python,lastline=8,numbers=left,showspaces=true,stepnumber=3]
184 def func(param):
185     'this is a python function'
186     pass
187 def func(param):
188 'This is a German word: Tschüß'
189 pass
190 def func(param):
191 'this is a python function'
192 pass
193 \end{lstlisting}
194
195 Special cases:
196 \begin{lstlisting}[abovecaptionskip=2em,basicstyle={\large\ttfamily},breaklines=true,extendedchars=true,firstline=2,float=h,language={[R/3 3.1]ABAP},lastline=5,numbers=left,numberstyle={\scriptsize},showspaces=true,showstringspaces=false,stepnumber=3,tabsize=4]
197 hello
198 \end{lstlisting}
199
200 \lstinline[language=TeX]!\begin{centering} hello!
201
202
203 \section{Graphics\index{Graphics}}
204
205 There is also some basic support for graphics, in the form
206 \includegraphics{foo.eps}, or the slightly more elaborate
207 \includegraphics[bb=10bp 0bp 96bp 96bp,clip,height=1cm, width=1cm]{foo.eps}.
208
209 \section{Tables\index{Tables}}
210
211 The following example is stolen from the longtable documentation.
212 Since tex2lyx does not understand the special verbatim code that
213 was used in the original some lines have been rewritten using
214 \textbackslash textbackslash etc.
215 \let\package\textsf
216 \let\env\textsf
217 \let\code\texttt
218 \providecommand\finalclearpage{\clearpage}
219
220 \begin{longtable}{@{*}r||p{1in}@{*}}
221 KILLED & LINE!!!! \kill
222 \caption
223 [An optional table caption (used in the list of tables)]
224 {A long table\label{long}}\\
225 \hline\hline
226 \multicolumn{2}{@{*}c@{*}}%
227      {This part appears at the top of the table}\\
228 \textsc{First}&\textsc{Second}\\
229 \hline\hline
230 \endfirsthead
231 \caption[]{(continued)}\\
232 \hline\hline
233 \multicolumn{2}{@{*}c@{*}}%
234       {This part appears at the top of every other page}\\
235 \textbf{First}&\textbf{Second}\\
236 \hline\hline
237 \endhead
238 \hline
239 This goes at the&bottom.\\
240 \hline
241 \endfoot
242 \hline
243 These lines will&appear\\
244 in place of the & usual foot\\
245 at the end& of the table\\
246 \hline
247 \endlastfoot
248 \env{longtable}  columns  are specified& in the \\
249 same way as  in the \env{tabular}& environment.\\
250 \code{@\{*\}r||p\{1in\}@\{*\}}& in this case.\\
251 Each row ends with a& \code{\textbackslash\textbackslash} command.\\
252 The \code{\textbackslash\textbackslash} command  has an& optional\\
253 argument, just as in& the\\
254  \env{tabular}&environment.\\[10pt]
255 See the effect of \code{\textbackslash\textbackslash[10pt]}&?\\
256 Lots of lines& like this.\\
257 Lots of lines& like this.\\
258 Lots of lines& like this.\\
259 Lots of lines& like this.\\
260 Also \code{\textbackslash hline} may be used,&  as in \env{tabular}.\\
261 \hline
262 That  was a \code{\textbackslash hline}&.\\
263 \hline\hline
264 That  was \code{\textbackslash hline\textbackslash hline}&.\\
265 \multicolumn{2}{||c||}%
266 {This is a \code{\textbackslash multicolumn\{2\}\{||c||\}}}\\
267 If a  page break  occurs at a \code{\textbackslash hline} then& a line is drawn\\
268 at the bottom of one  page  and at the& top of the next.\\
269 \hline
270 The \code{[t] [b] [c]} argument of \env{tabular}& can  not be used.\\
271 The optional argument may be  one of& \code{[l] [r] [c]}\\
272 to specify whether  the  table  should be& adjusted\\
273 to the  left, right& or centrally.\\
274 \hline\hline
275 Lots of lines& like this.\\
276 Lots of lines& like this.\\
277 Lots of lines& like this.\\
278 Lots of lines& like this.\\
279 Lots of lines& like this.\\
280 Lots of lines& like this.\\
281 Lots of lines& like this.\\
282 Lots of lines& like this.\\
283 Lots of lines& like this.\\
284 Lots of lines& like this.\\
285 Lots of lines& like this.\\
286 Lots of lines& like this.\\
287 Lots of lines& like this.\\
288 Lots of lines& like this.\\
289 Lots of lines& like this.\\
290 Lots of lines& like this.\\
291 Lots of lines& like this.\\
292 Lots of lines& like this.\\
293 Lots of lines& like this.\\
294 Lots of lines& like this.\\
295 Some lines may take up a lot of space, like this: &
296     \raggedleft This last column is a ``p'' column so this
297     ``row'' of the table can take up several lines. Note however that
298     \TeX\ will  never break a page within such a row. Page breaks only
299     occur between rows of the table or at \code{\textbackslash hline} commands.
300     \tabularnewline
301 Lots of lines& like this.\\
302 Lots of lines& like this.\\
303 Lots of lines& like this.\\
304 Lots of lines& like this.\\
305 Lots of lines& like this.\\
306 Lots of lines& like this.\\
307 Lots of lines& like this.\\
308 \hline
309 Lots\footnote{This is a footnote.} of lines& like this.\\
310 Lots   of   lines& like this\footnote{\env{longtable} takes special
311     precautions, so that footnotes may also be used in `p' columns.}\\
312 \hline
313 Lots of lines& like this.\\
314 Lots of lines& like this.
315 \end{longtable}
316
317 From bug 7412 another example with more captions (can currently not produced in LyX):
318 \begin{longtable}{|l|l|}
319 \caption{A long table}
320 \endfirsthead
321 \caption{A long table -- continued}
322 \endhead
323 \multicolumn{2}{r}{{Continued on next page}}
324 \tabularnewline
325 \endfoot
326 \endlastfoot
327 \hline
328 \multicolumn{1}{|c|}{Something} & \multicolumn{1}{c|}{Description}\tabularnewline
329 \hline Lots of lines& like this.\\
330 \hline Lots of lines& like this.\\
331 \hline Lots of lines& like this.\\
332 \hline Lots of lines& like this.\\
333 \hline Lots of lines& like this.\\
334 \hline Lots of lines& like this.\\
335 \hline Lots of lines& like this.\\
336 \hline Lots of lines& like this.\\
337 \hline Lots of lines& like this.\\
338 \hline Lots of lines& like this.\\
339 \hline Lots of lines& like this.\\
340 \hline Lots of lines& like this.\\
341 \hline Lots of lines& like this.\\
342 \hline Lots of lines& like this.\\
343 \hline Lots of lines& like this.\\
344 \hline Lots of lines& like this.\\
345 \hline Lots of lines& like this.\\
346 \hline Lots of lines& like this.\\
347 \hline Lots of lines& like this.\\
348 \hline Lots of lines& like this.\\
349 \hline Lots of lines& like this.\\
350 \hline Lots of lines& like this.\\
351 \hline Lots of lines& like this.\\
352 \hline Lots of lines& like this.\\
353 \hline Lots of lines& like this.\\
354 \hline Lots of lines& like this.\\
355 \hline Lots of lines& like this.\\
356 \hline Lots of lines& like this.\\
357 \hline Lots of lines& like this.\\
358 \hline Lots of lines& like this.\\
359 \hline Lots of lines& like this.\\
360 \hline Lots of lines& like this.\\
361 \hline Lots of lines& like this.\\
362 \hline Lots of lines& like this.\\
363 \hline Lots of lines& like this.\\
364 \hline Lots of lines& like this.\\
365 \hline Lots of lines& like this.\\
366 \hline Lots of lines& like this.\\
367 \hline Lots of lines& like this.\\
368 \hline Lots of lines& like this.\\
369 \hline Lots of lines& like this.\\
370 \hline
371 \end{longtable}
372
373 A table*:
374
375 \begin{tabular*} % some comment
376 {0.8\columnwidth}[b]{lr}
377 two\\
378 lonely&lines
379 \end{tabular*}
380
381 A booktabs table:
382
383 \begin{table}[h]
384 \caption{\label{tab:Special-booktabs-table}Special booktabs-table}
385
386
387 \centering{}%
388 \begin{tabular}{cccc}
389 \toprule 
390 System & Chip\,1 & \multicolumn{2}{c}{Chip\,2}\tabularnewline
391 \cmidrule(r){2-2}\cmidrule(l){3-4}\morecmidrules \cmidrule{2-4}Detector
392 thickness in \textmu{}m & 300 & 300 & 700\tabularnewline
393 \midrule 
394 Edge angle in \textdegree{} & 3.55 & 2.71 & 7.99\tabularnewline
395 \addlinespace
396 Spatial resolution in \textmu{}m & 4.26 & 10.17 & 10.56\tabularnewline
397 \addlinespace
398 MTF at $f_{\mathrm{max}}$ & 0.53 & 0.37 & 0.39\tabularnewline
399 \midrule 
400 \morecmidrules \cmidrule{3-4}LSF-spatial resolution &  &  & \tabularnewline
401 in \textmu{}m & 129.7 & 52.75 & 50.78\tabularnewline
402 in \% of pixel size & 76.3 & 95.9 & 92.3\tabularnewline
403 \bottomrule
404 \end{tabular}
405 \end{table}
406
407
408 \section{Macros}
409
410 LyX supports several kinds of macros:
411 def \def\macroa#1{a #1 a}
412 global def \global\def\macrob#1{b #1 b}
413 long def \long\def\macroc#1{c #1 c}
414 global long def \global\long\def\macrod#1{d #1 d}
415 providecommand \providecommand{\macroe}[1]{e #1 e}
416 providecommand* \providecommand*{\macrof}[1]{f #1 f}
417 newcommand \newcommand{\macrog}[1]{g #1 g}
418 renewcommand \renewcommand{\macrog}[1]{h #1 h}
419 newcommand* \newcommand*{\macroi}[1]{i #1 i}
420 renewcommand* \renewcommand*{\macroi}[1]{j #1 j}
421 providecommandx \providecommandx{\macrok}[1]{k #1 k}
422 providecommandx* \providecommandx*{\macrok}[1]{l #1 l}
423 newcommandx \newcommandx{\macrom}[1]{m #1 m}
424 renewcommandx \renewcommandx{\macrom}[1]{n #1 n}
425 newcommandx* \newcommandx*{\macroo}[1]{o #1 o}
426 renewcommandx* \renewcommandx*{\macroo}[1]{p #1 p}
427 DeclareRobustCommand \DeclareRobustCommand{\macroq}[1]{q #1 q}
428 DeclareRobustCommand* \DeclareRobustCommand*{\macror}[1]{r #1 r}
429 DeclareRobustCommandx \DeclareRobustCommandx{\macros}[1]{s #1 s}
430 DeclareRobustCommandx* \DeclareRobustCommandx*{\macrot}[1]{t #1 t}
431
432 Now use them all:
433 \macroa{x} \macrob{x} \macroc{x} \macrod{x} \macroe{x} \macrof{x} \macrog{x}
434 \macroi{x} \macrok{x} \macrom{x} \macroo{x} \macroq{x} \macror{x}
435 The following tow don't work, but they should???
436 %\macros{x} \macrot{x}
437
438
439 \section{Special formattings\index{Special formattings}}
440
441 \subsection{LyX line}
442
443 test
444
445 {\tiny \lyxline{\tiny}}{\tiny \par}
446
447 test {\Huge Test} {\tiny test} test
448
449 \lyxline{\normalsize}
450
451 test
452
453 {\Huge \lyxline{\Huge}}{\Huge \par}
454
455
456 \subsection{rules}
457
458 test\rule[0.001\textwidth]{1\columnwidth}{0.05\textheight}
459
460 test
461
462 \rule[0.5ex]{1\columnwidth}{1pt}
463
464 \noindent \rule{1ex}{0.5cc}test
465
466 \textcolor{red}{\rule[-4ex]{5in}{1cm}}
467
468
469 \subsection{Phantoms}
470
471 test\phantom{Wow}test
472
473 test\hphantom{\textcolor{green}{W}\textbf{ow}\textsuperscript{Wow}}test
474
475 test\vphantom{Wow\textbackslash{}\&\%}test
476
477 $test\hphantom{Wow}test$
478
479 \[
480 test\phantom{\textcolor{green}{W}\mathbf{ow}\textsuperscript{Wow}}test
481 \]
482
483
484 $test\vphantom{Wow\&\%}test$
485
486
487 \subsection{Line breaks\sindex[breaks]{Line breaks}}
488
489 They can also or be broken by a newline\\
490 or by a starred newline \\*
491 or by a newline with space, comment and argument \\ %hu
492 [3cm]
493 or by a newline command \newline
494 or by a line break \linebreak
495 or by a defined line break \linebreak % again with a comment
496         [4]
497
498 There are even newlines with weird arguments, but these are not
499 handled by LyX\\*[1cm]
500 so we try to use ERT in this case.
501
502 \subsection{Page breaks\sindex[breaks]{Page breaks}}
503
504 They can also or be broken by a newpage \newpage
505 or by a page break \pagebreak
506 or by a defined page break \pagebreak % again with a comment
507         [4]
508
509 \section{Special characters\index{Special characters}}
510
511 Then one has those macros with a long name for a short meaning, like
512 \textasciitilde, \textasciicircum{} or \textbackslash{}, \slash{},
513 \nobreakdash- and the characters
514 that LaTeX wants to espace because they are active, like \_\&\#\$\{\}\%.
515
516 And what about special characters like hyphe\-nation mark,
517 ellipsis\ldots, and end-of-sentence\@. LyX also supports a menu
518 separator\lyxarrow{}and a spif\textcompwordmark{}fy ligature break.
519
520 LyX translates the phrases LyX, TeX, LaTeX2e and LaTeX
521 to the commands \LyX{}, \TeX{}, \LaTeXe{} and \LaTeX{}.
522 If these phrases occur as part of other words (like 1LyX or aTeX or LaTeX3)
523 they should not be put into ERT.
524
525 Test for whitespace handling of commands: The following lines should
526 result in identical output:
527
528 builtin \textasciicircum{} unicodesymbols \j{} user \mycommand{} xx\par
529 builtin \textasciicircum {} unicodesymbols \j {} user \mycommand{} xx\par
530 builtin \textasciicircum % with a comment
531 {} unicodesymbols \j % and a second one
532 {} user \mycommand % and another
533 {} xx
534
535 A sub\textsubscript{sc\emph{ript}} and super\textsuperscript{script
536 with $a^2+b^2=c^2$ math}.
537
538 \section{Mathematics\index{Mathematics}}
539
540 Let $f:\left[  a,b\right]  \rightarrow%
541 %TCIMACRO{\U{211d} }%
542 %BeginExpansion
543 \mathbb{R}
544 %EndExpansion
545 $.
546
547 \printindex{}
548
549 \printnomenclature hello
550
551 \settowidth{\nomlabelwidth}{URL2}
552 \printnomenclature{}
553
554 \printnomenclature[0.02\linewidth]{}
555
556 \end{document}