3

I just started using Lyx and I'm very confused. It doesn't allow me to show the LaTeX code so that I cannot edit LaTeX directly. But it also has no apparent options to set certain things.

What I need is this:

the tex

7
  • This depends on the packages and the documentclass, but I would try either fancyhdr package or the KOMA classes for this
    – user31729
    Feb 21, 2015 at 20:05
  • I should've pointed out I'm a beginner with LaTeX. Therefore I have frankly no idea what are you talking about. I tried putting some fancyhdr commands in LaTeX preambule, but where to put the desired information I have no idea. I found these codes here, on tex.SE - so yes, I have been searching a lot before posting. Feb 21, 2015 at 20:08
  • You might wanna tell us a bit more about what kind of document you are working on. You can also read LaTeX for complete novices to make a decision on your own.
    – Johannes_B
    Feb 21, 2015 at 20:34
  • I am pretty sure that it's possible to enter LateX code directly into LyX editor.
    – user31729
    Feb 21, 2015 at 20:47
  • @ChristianHupfer yes, but it doesn't render then. It remains in a red block and only renders when you compile to PDF. Also can you explain your edit on my question? LyX or LaTeX are not code, they are platform names. I don't put Christian in code block, or should I? Feb 21, 2015 at 21:17

2 Answers 2

2

There are various possibilities, this just uses the scrbook class and the scrlayer-scrpage package, setting the headers for left-header-odd-page (\lohead), left-header-even-page (\lehead) and their corresponding commands for the right headers, as well as the centred head command \chead.

\documentclass{scrbook} % Koma book class
\usepackage{xcolor}
\usepackage{scrlayer-scrpage}

\newcommand{\MyName}{Tom\'a\v{s} Zato}

\usepackage{blindtext}

\clearscrheadfoot%
\rohead{\MyName}
\lehead{\today}

\chead{Project}
\lohead{\today}
\rehead{\MyName}    
\cefoot{\thepage}  % Page number in centred footer

\begin{document}
\pagestyle{scrheadings}

\blindtext[5]  % Filling the document
\end{document}

enter image description here

A version for an oneside book - document

\documentclass[oneside]{scrbook}

\usepackage{scrlayer-scrpage}

\newcommand{\MyName}{Tom\'a\v{s} Zato}

\usepackage{blindtext}
\clearscrheadfoot%
\ohead{\MyName}
\ihead{\today}
\chead{Project}
\begin{document}
\pagestyle{scrheadings}

\blindtext[6]


\end{document}
5
  • By the OPs input, i would guess this is a oneside document. Having the project name in the header also clues for oneside. Even if it would be twoside, having the name always on the right is messy. Decide for inner/center/outside. Makes less code as well.
    – Johannes_B
    Feb 21, 2015 at 20:32
  • @Johannes_B: I took my inspirations from the images ;-)
    – user31729
    Feb 21, 2015 at 20:33
  • The images clearly show an article-kind-of-document. :-p
    – Johannes_B
    Feb 21, 2015 at 20:35
  • @Johannes_B: Clearly? A sketch by hand identifies as article-like? (i.e. with equal margins)
    – user31729
    Feb 21, 2015 at 20:36
  • Never said article, but article-kind-of-document.
    – Johannes_B
    Feb 21, 2015 at 20:37
3

In the settings dialog click on the Modules option.

Select "Custom Header/Footerlines" from the "Available" list and then click on the "Add" button to make it active. Note the advice in the description pane that you must set the Page Layout to "fancy". (Click on the "Page Layout" option and select "fancy" from the "Page style" drop down. Click on "OK" to close the settings dialog.

This will then give you a series of environments in your environment list which you can insert into your LyX document which you can use to set headers and footers using LyX commands. For example, if you select "Left Header" from the list with your cursor in a new paragraph you will see the text "Left Header:" appear in your document. Just type the content of the header in this environment.

Personally, I set these up at the start of the document so they are easy to find.

No LaTeX or preamble changes necessary.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .