In the beginning I wanted a way to specify the rule length for each \epigraph
call. But after the suggestion given here, I ended up with some code that calculates the length of the rule like this: it is the length of either the text or the author, whichever is longer. Unless the length of the text (or of the author...) is larger the 80% of the width of the page, in which case the length of the rule (and the text/author) is set to 80% of that of the page. But as talking is cheap, here's the code:
\newcommand{\mytextformat}{\itshape\epigraphsize}
\newcommand{\mysourceformat}{\scshape}
\newenvironment{mytext}{\mytextformat}{}
\newenvironment{mysource}{\mysourceformat\hfill}{}
\renewcommand{\textflush}{mytext}
\renewcommand{\sourceflush}{mysource}
\newlength{\epitextlen}
\newlength{\episourcelen}
\newlength{\epilength}
\let\originalepigraph\epigraph
\renewcommand\epigraph[2]%
{%
\setlength{\epitextlen}{\widthof{\mytextformat#1}}%
\setlength{\episourcelen}{\widthof{\mysourceformat#2}}%
\ifdim\epitextlen>\episourcelen%
\setlength{\epilength}{\epitextlen}%
\else%
\setlength{\epilength}{\episourcelen}%
\fi%
\ifdim\epilength>0.8\textwidth%
\setlength{\epilength}{0.8\textwidth}%
\fi%
\setlength{\epigraphwidth}{\epilength}%
\originalepigraph{#1}{#2}%
}
It works well, but as I am new to TeX hackery, I wanted to ask if/how it could be improved? In particular, when the author's name is larger than the text, some is left before it. It's not too serious, but if anyone can tell me why, I'd appreciate it. Thanks in advance.
EDIT: Here's the MWE. @Steven B. Segletes: changing the \mysourceformat
line as you suggest causes the author line to be wrapped into two lines.
\documentclass[oneside]{scrbook}
\usepackage{epigraph}
\usepackage{calc}
\newcommand{\mytextformat}{\itshape\epigraphsize}
\newcommand{\mysourceformat}{\scshape}
\newenvironment{mytext}{\mytextformat}{}
\newenvironment{mysource}{\mysourceformat\hfill}{}
\renewcommand{\textflush}{mytext}
\renewcommand{\sourceflush}{mysource}
\newlength{\epitextlen}
\newlength{\episourcelen}
\newlength{\epilength}
\let\originalepigraph\epigraph
\renewcommand\epigraph[2]%
{%
\setlength{\epitextlen}{\widthof{\mytextformat#1}}%
\setlength{\episourcelen}{\widthof{\mysourceformat#2}}%
\ifdim\epitextlen>\episourcelen%
\setlength{\epilength}{\epitextlen}%
\else%
\setlength{\epilength}{\episourcelen}%
\fi%
\ifdim\epilength>0.8\textwidth%
\setlength{\epilength}{0.8\textwidth}%
\fi%
\setlength{\epigraphwidth}{\epilength}%
\originalepigraph{#1}{#2}%
}
\begin{document}
\chapter{Introduction}
\epigraph{IRAV IVQV IVPV}{Gaius Julius C\ae sar} Lorem ipsum.
\end{document}