It depends on what you want. Do you want onesided printed documents or doublesided documents? One sided documents have the same margins on the right and left side, double sided documents have margins builded like this: outer margin = 2 * inner margin, for example for a right side:
outer margin (right one, 4cm) = inner margin (left one, 2cm) * 2
The result is that you get a good looking book with 3 same margins: left (4cm) = inner (2cm+2cm=4cm) = right (4cm).
Document class scrartcl
and scrreprt
are one sided, scrbook
is doublesided. If you want to change this you can add the document class option oneside
or twoside
.
Try this MWE and play with the comment signs:
%http://tex.stackexchange.com/questions/85884/koma-script-unequal-left-right-margin
\documentclass[%
oneside % prints one sided; twoside is standard for scrbook
% twoside % prints double sided documents
,fontsize=11pt % fontsize for standard font
]{scrbook} % scrartcl scrreprt scrbook
\usepackage{amsmath,amssymb,amsfonts,hyperref}
\usepackage{showframe} % shows typing area with frames; for test only!
\begin{document}
\large
%%% Header %%%
\title{My Title}
\author{John J. Johnson}
\date{December 2012}
\maketitle
\end{document}
The inner title of a book is always printed in the area used in the book, the envelope of the book can be build differently.
If you want to make an envelope for your work, use a separate file with one sided printing. With KOMA-Script you can use the environment titlepage
to create your own title pages. In the manual you will find this ...
Here's one possible solution; the basic idea is to capture the title (#1
in the explicit
option for titlesec
), to box it inside a varwidth
environment and decide the length of the rule to be used (\ftitlewd+2pc
) , by using a conditional test comparing the actual width of the title (\titlewd
) and the width that was initially reserved to typeset it (\titleboxwd=\textwidth-\mylen=\textwidth-3pc
):
\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{varwidth}
\usepackage[calcwidth,explicit]{titlesec}
\usepackage{lipsum}
\newlength\mylen
\newsavebox\mybox
\newlength\titlewd
\newlength\ftitlewd
\newlength\titleboxwd
\setlength\mylen{3pc}
\setlength\titleboxwd{\dimexpr\textwidth-\mylen\relax}
\setlength\ftitlewd{\titleboxwd}
\newcommand\chapfont{\Huge\bfseries\raggedleft}
\titleformat{\chapter}[hang]
{\chapfont\filleft}
{}{0pc}
{\parbox[t]{\mylen}{\textcolor{gray}{\thechapter}\hfill}%
\begin{lrbox}{\mybox}%
\begin{varwidth}[t]{\titleboxwd}%
\chapfont#1%
\end{varwidth}%
\end{lrbox}%
\settowidth\titlewd{\usebox\mybox}%
\ifdim\titlewd<\titleboxwd%
\global\setlength\ftitlewd{\titlewd}%
\fi%
\parbox[t]{\ftitlewd}{\usebox\mybox}%
}
[\vskip-1.4ex{\makebox[0pt][l]{%
\hspace*{-\ftitlewd}\rule{\dimexpr\ftitlewd+2pc\relax}{1.5pt}}}%
]
\titleformat{name=\chapter,numberless}[hang]
{\chapfont\filleft}
{}{0pc}
{%
\begin{lrbox}{\mybox}%
\begin{varwidth}[t]{\titleboxwd}%
\chapfont#1%
\end{varwidth}%
\end{lrbox}%
\settowidth\titlewd{\usebox\mybox}%
\ifdim\titlewd<\titleboxwd%
\global\setlength\ftitlewd{\titlewd}%
\fi%
\parbox[t]{\ftitlewd}{\usebox\mybox}%
}
[\vskip-1.4ex{\makebox[0pt][l]{%
\hspace*{-\ftitlewd}\rule{\dimexpr\ftitlewd+2pc\relax}{1.5pt}}}%
]
\titlespacing*{\chapter}
{1\mylen}{50pt}{40pt}
\begin{document}
\chapter*{An Unnumbered Chapter}
\lipsum[4]
\chapter{A tremendously Long Chapter Title Showing a Solution}
\lipsum[4]
\chapter{Short Chapter Title}
\lipsum[4]
\end{document}
Some images of the resulting chapter headings: first, an unnumbered chapter (this will be the formatting fot the ToC, LoF, LoT and bibliography):
A numbered chapter with a long title:
and a numbered chapter with a short title:
Feel free to change the lengths to suit your needs.
As a personal note (of course, not more than a suggestion), with the requested layout, the position of the chapter number will vary from chapter to chapter and I am not sure that this is a good choice. Perhaps you could reconsider this.
The following variation places the chapter number outside the right margin, at the same distance that the rule protusion:
\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{varwidth}
\usepackage[calcwidth,explicit]{titlesec}
\usepackage{lipsum}
\newsavebox\mybox
\newlength\mylen
\newlength\titlewd
\newlength\ftitlewd
\newlength\titleboxwd
\setlength\mylen{3pc}
\setlength\titleboxwd{\dimexpr\textwidth-\mylen\relax}
\setlength\ftitlewd{\titleboxwd}
\newcommand\chapfont{\Huge\bfseries\raggedleft}
\titleformat{\chapter}[hang]
{\chapfont\filleft}
{}{0pc}
{%
\begin{lrbox}{\mybox}%
\begin{varwidth}[t]{\titleboxwd}%
\chapfont#1%
\end{varwidth}%
\end{lrbox}%
\settowidth\titlewd{\usebox\mybox}%
\ifdim\titlewd<\titleboxwd%
\global\setlength\ftitlewd{\titlewd}%
\fi%
\parbox[t]{\ftitlewd}{\usebox\mybox}%
\makebox[0pt][l]{\parbox[t]{4pc}{\hfill\textcolor{gray}{\thechapter}}}%
}
[\vskip-1.4ex{\makebox[0pt][l]{%
\hspace*{-\ftitlewd}\rule{\dimexpr\ftitlewd+4pc\relax}{1.5pt}}}%
]
\titleformat{name=\chapter,numberless}[hang]
{\chapfont\filleft}
{}{0pc}
{%
\begin{lrbox}{\mybox}%
\begin{varwidth}[t]{\titleboxwd}%
\chapfont#1%
\end{varwidth}%
\end{lrbox}%
\settowidth\titlewd{\usebox\mybox}%
\ifdim\titlewd<\titleboxwd%
\global\setlength\ftitlewd{\titlewd}%
\fi%
\parbox[t]{\ftitlewd}{\usebox\mybox}%
}
[\vskip-1.4ex{\makebox[0pt][l]{%
\hspace*{-\ftitlewd}\rule{\dimexpr\ftitlewd+4pc\relax}{1.5pt}}}%
]
\titlespacing*{\chapter}
{1\mylen}{50pt}{40pt}
\begin{document}
\chapter*{An Unnumbered Chapter}
\lipsum[4]
\chapter{A tremendously Long Chapter Title Showing a Solution}
\lipsum[4]
\chapter{Short Chapter Title}
\lipsum[4]
\end{document}
The corresponding images:
Best Answer
Here is a another suggestion
Note that I would use
open=right
if the chapter number should be in the right margin.Result:
Update as answer of a comment below:
If you want to use
\MakeUppercase
for the chapter titles you can redefine\chapterlinesformat
. Note that the following example needs at least KOMA-Script version 3.19: