1

I have created a newcommand to format titles in my prayer book. I want the newcommand to be centered, but with the following code, there is extra space above and below the newcommand. I tried to use \centering instead of \begin{center} \end{center}. but it doesn't compile centered.

\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{xcolor}

\newcommand{\prayerheading}[1]{% \begin{center} \noindent\large\bfseries\textcolor{red}{#1}\normalsize \end{center} }

\newcommand{\psalmheading}[1]{% {\centering \noindent\large\bfseries\textcolor{red}{#1}\normalsize } }

\title{Test} \author{Michael} \begin{document} \maketitle

\prayerheading{Introductory Prayer}

In the name of the Father, and of the Son, and of the Holy Spirit. Amen.\

Glory to Thee, our God, glory to Thee.\

\prayerheading{Evening Troparia}

Have mercy on us, O Lord have mercy on us, for laying aside all excuse, we sinners offer to Thee as to our Master this supplication: have mercy on us.\

\psalmheading{Evening Troparia}

Have mercy on us, O Lord have mercy on us, for laying aside all excuse, we sinners offer to Thee as to our Master this supplication: have mercy on us.\

\end{document}

I'm sorry I keep having issues having all the text that's in the code edited properly. So, I am trying to keep the look of the original code: \prayerheading but without the extra spacing above and below.

Thanks

David Carlisle
  • 757,742
Doc
  • 51
  • 6

1 Answers1

1

(added \medskip and \smallskip directives to the definition of \psalmheading per the OP's request)

So, I am trying to keep the look of the original code [for \psalmheading]: \prayerheading but without the extra spacing above and below.

Something like this?

enter image description here

\documentclass[12pt]{article}

\usepackage[document]{ragged2e} \usepackage{xcolor}

\newcommand{\prayerheading}[1]{% \begin{center} \large\bfseries\color{red}#1 \end{center} }

\newcommand{\psalmheading}[1]{% \begingroup \par\medskip% <-- new: \medskip \centering\large\bfseries\color{red}#1 \par\smallskip% <-- new: \smallskip \endgroup}

\begin{document}

\prayerheading{Introductory Prayer}

In the name of the Father, and of the Son, and of the Holy Spirit. Amen.

Glory to Thee, our God, glory to Thee.

\prayerheading{Evening Troparia}

Have mercy on us, O Lord have mercy on us, for laying aside all excuse, we sinners offer to Thee as to our Master this supplication: have mercy on us.

\psalmheading{Evening Troparia}

Have mercy on us, O Lord have mercy on us, for laying aside all excuse, we sinners offer to Thee as to our Master this supplication: have mercy on us.

\end{document}

Mico
  • 506,678
  • @Teepeemm - Thanks for pointing out that there was an issue with my code. – Mico Jul 08 '23 at 03:35
  • Is there a way to "add back" some of the space between the command and the next line, but not as much as I had with the initial MWE? – Doc Jul 08 '23 at 22:47
  • @Doc - Please be more specific as to what kind of "add back" you have in mind. – Mico Jul 08 '23 at 23:02
  • 1
    The code provided in the answer above \newcommand{\psalmheading}[1]{% \begingroup\par\centering\large\bfseries\color{red}#1\par \endgroup}' The "heading" provided by the command\psalmheading' now is directly above the following text, and while I am not wanting as much space as in my code \newcommand{\prayerheading}[1]{% \begin{center} \large\bfseries\color{red}#1 \end{center}}' I do want some space maybe half as much as my code with the\begin{center}' provdes. – Doc Jul 11 '23 at 23:21
  • 1
    @Doc - I've gone ahead and modified the definition of \psalmheading to (hopefully) meet your request. If the amount of additional whitespace still doesn't meet your requirements, please feel free to use \bigskip instead of \medskip and/or \smallskip. – Mico Jul 12 '23 at 04:32