LyX tips and tricks
In this article I will describe interesting hack and possibilities which I use
from time to time in LyX, like default setting for all code listings,
shortcut for --Separator--
layout and so on.
How to set custom settings for all program listings ?
If you exhausted to setup every code-listing you have, you can set default parameters for all existed and future ones:
- Go to Document > Document Settings > Listings
- Insert settings what you need
I have used only basicstyle={\ttfamily}
-- use Typewriter font all the time,
but you can easily find other necessary settings in the
listings package doc and in the web.
How to create shortcut for Separator layout ?
Actually, shortcuts in LyX is not very clear yet. It can take a long time
to find correct command to set/change a shortcut for it.
If you type a lot, you may noticed there are shortcuts almost for all
standard layouts, like Part, Section, Description and so on...
but there is no one for --Separator--
layout.
You can fix it easily in the next manner:
- Go to Tools -> Preferences -> Editing -> Shortcats
- Press [New] button
- In [Function] field input
command-sequence layout --Separator--;
- Press on empty button next to Delete Key, and setup some shortcut
(I use[Alt+P -]
; i.e. PressAlt+P
, release, and press minus-
) - Press Ok ->Apply ->Save ->Close
- Enjoy it!
How to start enumerate list from different number ?
- Start a numbered list (
[Alt+P E]
) - Insert TeX-code (
[Ctrl+L]
) - Write
[0.]\setcounter{enumi}{0}
(to start list from zero) - Exit TeX-block and write elements as usual.
What is the magic [num1.]\setcounter{enumi}{num2}
?
Well, it's a little hack that says:
- current item should be looked like an item with number num1;
- set real number of current item to num2, so next item will be numbered as num2+1 and so on.
So, if you use TeX-code like [10.]\setcounter{enumi}{20}
-- this element will
be marked as 10, but next element will be marked as 21.
Of course, you can use this hack for any item in numbered list.
How to rotate a specific page ?
To rotate page, just add package \usepackage{pdflscape}
in Document LaTeX Preamble
and then:
- add
\begin{landscape}
as TeX-code([Ctrl+L]
) at the beginning of the needed page; - write your text as usual;
- add
\end{landscape}
as TeX-code at the end of the needed page.
Then marked page will be in landscape rotation.
Useful LaTeX Preamble
There are plenty of little TeX-hacks, that allow you improve document in many ways. I will describe here the most common. Go to Document ->Settings... ->LaTeX Preamble, and you can paste there something like
\usepackage{indentfirst} % indent first line after headers (ie red line)
\sloppy % deny to put text beyond margins of document
\usepackage{pdflscape} % add possibility for landscape pages
How to skip page number on some pages ?
- At the end of the page that you want to be clear (most of time it is title page)
insert following TeX-code(
[Ctrl+L]
):\thispagestyle{empty}