Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to have

  • Title flush left
  • Author flush right
  • Date flush right

How can I do this on the same line or on a shared line? I was hope to achieve the following:

Title Author Date shared line

This is as far as I got using xelatex:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{titlesec, blindtext, color}
\definecolor{gray75}{gray}{0.75}
\newcommand{\hsp}{\hspace{20pt}}
\titleformat{\section}[hang]{\Huge\bfseries}{Woche\hspace{.3cm}\thesection\hsp\textcolor{gray75}{|}\hsp}{0pt}{\Huge\bfseries}

\usepackage{titling}
\pretitle{\begin{minipage}{0.4\textwidth}\begin{flushleft}\Huge}
\posttitle{\end{flushleft}\end{minipage}\hfill}
\predate{\hfill\begin{minipage}[t]{0.4\textwidth}\begin{flushright}\large}
\postdate{\end{flushright}\end{minipage}}

\title{Class Plan}

\begin{document}
\maketitle
\section{Less is More}
\blindtext
\end{document}

There is one catch. I need this to work in my .emacs file. I would like the MACRO #+Title and #+Author to work without extra code in my org-mode file

share|improve this question
add comment

1 Answer 1

up vote 8 down vote accepted

The key is using boxes, in this case \parboxes (which allow for line breaks, as needed on the right) and putting them on the very left and right with \hfill in between.

Besides that, I wouldn't try to fix up \maketitle if I don't absolutely have to, but instead just create the title from scratch. To access the values of \author and \title, we can use the titling package.

The section titles can be done with a quick fix, too.

Here are a basic version and one that's closer to your image:

\documentclass{article}

\usepackage{titling}
    \author{Author}
    \title{Class Plan}
    \date{\today}

\usepackage{xcolor}
    \definecolor{titlebg}{RGB}{186,48,39}

\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{blindtext}

\renewcommand{\thesection}{Week \arabic{section}\hspace{1em}|}

\begin{document}

Basic version: \bigskip

\noindent\parbox{\linewidth}{%
\parbox{.4\linewidth}{\fontsize{24}{28}\selectfont\thetitle}\hfill%
\parbox{.4\linewidth}{\fontsize{12}{14}\selectfont\raggedleft\today\\\theauthor%
}}

\bigskip Fancier version: \bigskip

\noindent\colorbox{titlebg}{%
\parbox{\dimexpr\linewidth-2\fboxsep}{\color{white}%
\parbox{.4\linewidth}{\fontsize{24}{28}\selectfont\sffamily\bfseries\thetitle}\hfill%
\parbox{.4\linewidth}{\fontsize{12}{14}\selectfont\raggedleft\thedate\\\theauthor%
}}}

\section{Less is More}
\blindtext
\end{document}

output


Edit:

As egreg said, just redefine \maketitle as a whole and put this in a .sty file:

\renewcommand*{\maketitle}{\noindent\colorbox{titlebg}{%
\parbox{\dimexpr\linewidth-2\fboxsep}{\color{white}%
\parbox{.4\linewidth}{\fontsize{24}{28}\selectfont\sffamily\bfseries\thetitle}\hfill%
\parbox{.4\linewidth}{\fontsize{12}{14}\selectfont\raggedleft\today\\\theauthor%
}}}}

I'm not familiar with emacs at all, so I can't help you with that, if the package solution is not what you're looking for. In that case, I would probably recommend asking a separate question about what you're trying to do because it seems to be independent from the styling of the title (obeying our one-issue-per-question guideline).

Some resources on writing a package (= .sty file):

share|improve this answer
    
I did mark your answer as correct, but perhaps it was premature. It did indeed answer my question, however, I did not make my question clear enough. My ultimate goal is to include all of this in my .emacs file for a xelatex export. I was hoping to keep my solution above the \begin{document}, but your solution involves code below this point. Do you know how I could solve this? That is why I wanted to edit the \maketitle and I think in this case, I have to! –  macmadness86 Nov 5 '12 at 18:47
1  
@macmadness86 The right place for that kind of code is not the .emacs file, but rather a personal .sty file. Just put the relevant code in a redefinition of \maketitle, inside macmadness.sty and do \usepackage{macmadness} after storing the package in one of the canonical places (~/Library/texmf/tex/latex/macmadness on Mac OS X with MacTeX). –  egreg Nov 5 '12 at 19:05
    
@macmadness86: I agree with egreg, and see my edit. –  doncherry Nov 5 '12 at 19:16
1  
@doncherry i meant between tex live installs. so that i can compile a file on any computer without needed to install a style file first. You make it sound fantastic though. You should go into sty file marketing :) –  macmadness86 Nov 5 '12 at 19:31
1  
@macmadness86 "Installing" a style file is as easy as putting it in the directory of the mydocument.tex file that you're compiling. If you want to make it as available on a system as any other .sty file, you'll have to put it in your texmf tree, as egreg indicated. –  doncherry Nov 5 '12 at 19:34
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.