4

How to center a verse horizontally

I am using solution give by @Herbet I try to add desired font size to the verse environment but it did not work for me. my entire document appears at font size 12. I want the verse to appear in font size 18. Rest of the document can stay at size 12.

There is a one line text on top of the verse, I want it to appear in font size 8 bold in red color. I do not know how to create a command for this so that I can use it and be able to change properties later. I would appreciate your help

2 Answers 2

7

You can change the font size using the \fontsize command; using \textcolor you can change the text color. An example (run it with XeLaTeX):

\documentclass[12pt]{article}
\usepackage{fontspec}
\usepackage{xcolor}
\usepackage{varwidth}
\newenvironment{Verse}
  {\center\varwidth{\linewidth}\fontsize{18}{21.6}\selectfont}
  {\endvarwidth\endcenter}    
\usepackage{lipsum}
\begin{document}

\lipsum[1]
\begin{Verse}
\textcolor{red}{\fontsize{8}{9.6}\selectfont\bfseries A line in bold red color}\\
foo bar\\
baz
\end{Verse}

\end{document}

enter image description here

In the preamble of your document, you could define a command to change the font size, color and series for the line of text:

\newcommand\RedLine[1]{%
  \textcolor{red}{\fontsize{8}{9.6}\selectfont\bfseries#1}
}

and then use it in the body of your document like

\RedLine{text with different font attributes}
5
  • I am working with these fonts Aksharyogini / Nakula / Sanskrit 2003, when i replace \bfseries with any one of these I get error, what am I doing wrong. how would I work with these font types. thanks for your help
    – Aku
    Oct 7, 2011 at 13:01
  • @Aku: I think it could be better to open a new question. You could link to this one, so people know that the new question is a follow up. Oct 7, 2011 at 13:35
  • This above solution seems don't have the normal verse function anymore, what if I just want to tweak the font size, font style a bit? will be great if it can be set up in Preamble.
    – Shi Yuan
    Feb 4, 2013 at 12:30
  • @ShiYuan you can patch the environment; perhaps asking a fresh new question would be better? I am not sure about your intent. Feb 5, 2013 at 17:10
  • @GonzaloMedina actually it has been answered. tex.stackexchange.com/questions/96759/…
    – Shi Yuan
    Feb 5, 2013 at 17:13
1
\documentclass[12pt]{book} 
\usepackage{fontspec}
\usepackage{lipsum}
\usepackage{varwidth}
\newenvironment{Verse}
  {\vspace{-1ex}\vspace{0pt}\center\varwidth{\linewidth}\itshape\fontsize{18pt}{22pt}\selectfont}
  {\endvarwidth\endcenter\vspace{-1ex}\vspace{20pt}}
\begin{document}
\lipsum[1]
\begin{Verse}
By geometric scale\\
Doth take the size of pots of ale.
\end{Verse}
\lipsum[1]
\end{document}

Space before the verse is removed, space after the verse is increased

Small adjustment of Gonzalo Medina's code. Now you can change the spaces before and after the verse.

1
  • 1
    Your answer would be greatly improved if you provide a complete minimum working example, starting with \documentclass and ending with \end{document}. Welcome to the site. Mar 27, 2015 at 23:30

You must log in to answer this question.

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