0

Consider the following minimal but working example.

\documentclass[landscape]{article}
\usepackage[a3paper, textwidth=7.5cm, margin=1cm,landscape]{geometry}
\usepackage{titlesec}
\usepackage{xcolor}


\newcommand{\mytitle}[1]{\colorbox{gray!40}{\makebox[\dimexpr\columnwidth-  2\fboxsep\relax]{\filcenter #1\strut}}}
\titleformat{\paragraph}
{\normalfont\normalsize\bfseries}{\theparagraph}{1em}{\mytitle}
\titlespacing*{\paragraph} {0pt}{3.25ex plus 1ex minus .2ex}{1em}

\begin{document}
    \thispagestyle{empty}
    \paragraph{Cheat Sheet Number Theory  (1/2) - X.005 --/12-'15}
\end{document}

I have a question about the custom \paragraph command. I would like to change this to the following format.

\paragraph{Left aligned text}{Centered heading}{Right aligned text}

When the first and third arguments are empty like so

\paragraph{}{B}{}

should produce the gray line with B centered just as it does now.

Also

\paragraph{A}{B}{}

should produce the gray line with A left aligned and B centered.

and

\paragraph{}{B}{C}

should produce the gray line with B centered and C right aligned.

Is this possible by modifying the preamble as listed above? If so, then please advise on how I should implement this.

7
  • I think your request is under-specified. Are the left and right text to start at the same vertical height and both take half the text width? Or do the left and right text both take full text width, but just align differently to the margins? In this latter case, they would not align vertically. Dec 3, 2015 at 11:10
  • Yes, at the same vertical height, like Left - Center - Right. On one line. Dec 3, 2015 at 11:12
  • 1
    "intuitively expected" can only be understood by you!! Also paragraphs are typically multiple lines, what does it mean to specify left and right aligned text at the same time? In any case it would be better to use a different command name \paragraph is a 4th level heading and should only be used in the sequence section, subsection,subsubsection, paragraph. Dec 3, 2015 at 11:25
  • @DavidCarlisle I edited the question. My document is not an article or a monograph but a collection of multicolumn pages with only paragraphs. Perhaps you are familiar with the cheatsheet/revision layout. Running the example code might clarify? Copy/paste should run immediately. Dec 3, 2015 at 12:39
  • yes I can see it is not an article that but as I say \paragraph seems to be a bad name. Also your question is still completely unclear are the three arguments single line? if so in what sense is this a paragraph at all? what is supposed to happen if the three arguments do not fit on a line? overprint? if so you can just do \colorbox{gray}{\rlap{#1}\hss#2\hss\llap{#3}} Dec 3, 2015 at 13:15

1 Answer 1

1

The question is massively unclear, and seems unrelated to paragraph setting at all but I think you are asking for

enter image description here

\do

cumentclass[landscape]{article}
\usepackage[a3paper, textwidth=7.5cm, margin=1cm,landscape]{geometry}
\usepackage{titlesec}
\usepackage{xcolor}


\newcommand{\mytitle}[3]{%
\par
\noindent
\colorbox{gray!40}{\makebox[\dimexpr\columnwidth-  2\fboxsep\relax]{%
\rlap{#1}\hfill\textbf{#2}\hfill\llap{#3}\strut}}\par}

\begin{document}

\mytitle{foo}{Cheat Sheet Number Theory  (1/2) - X.005 --/12-'15}{ba}

\mytitle{}{Cheat Sheet Number Theory  (1/2) - X.005 --/12-'15}{ba}

\mytitle{foo}{Cheat Sheet Number Theory  (1/2) - X.005 --/12-'15}{}

\end{document}
8
  • Yes, that is what I am asking for. Will try now. Dec 3, 2015 at 14:57
  • It is not working yet because of \titleformat{\paragraph} {\normalfont\normalsize\bfseries}{\theparagraph}{1em}{\mytitle} \titlespacing*{\paragraph} {0pt}{3.25ex plus 1ex minus .2ex}{1em} this has to do with the fact that the text might be printed in various formats. I'll see what I can do with it anyway. Later. Dec 3, 2015 at 15:05
  • @ndroock1 I can't guess what you mean by that comment, sorry, the code above doesn't use titlesec or \paragraph at all. Dec 3, 2015 at 15:28
  • I mean that in the example in the original question \paragraph{Cheat Sheet Number Theory (1/2) - X.005 --/12-'15} is used instead of \mytitle. That seems to work different. I did not write the code, I got it through a question here. Dec 3, 2015 at 15:32
  • @ndroock1 using \paragraph is wrong, I fixed that on purpose:-) Dec 3, 2015 at 15:34

You must log in to answer this question.

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