GeneralIssue with custom quotations in typewrite font

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
User avatar
Annabel
Posts: 14
Joined: Mon Jun 16, 2008 3:21 pm

Issue with custom quotations in typewrite font

Post by Annabel »

Hi all

I need different types of quotations in a letter for discussing the text of another document. Therefore, I want to create several environments that are all similar to the generic quotation environment, but having different fonts/font properties. In one of them I want to use the typewriter family of fonts. The problem that I have is that using \ttfamily interferes with latex hyphenation. I get lots of underfull and overfull box warnings and document layout is a mess (text in the right margin):

Code: Select all

\newenvironment{NewText}
    {\begin{quotation}\noindent\ttfamily}
    {\end{quotation}}
Also using a minipage environment does not solve the issue:

Code: Select all

\newenvironment{NewText}
    {\begin{center}\begin{minipage}[h]{.9\textwidth}\noindent\ttfamily}
    {\end{minipage}\end{center}}
Any suggestions?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Issue with custom quotations in typewrite font

Post by Stefan Kottwitz »

Hi Annabel,

welcome to the board!
You could get hyphenation for the standard typewriter font by:

Code: Select all

\usepackage[htt]{hyphenat}
I assume you will get underfull and overfull boxes still, even with hyphenation, because this monospaced font cannot be stretched or shrinked, even the blanks between the words. Perhaps consider to use a different font, not typewriter. With typewriter it can be solved too, have a look here: Full justification with typewriter font. If you have questions concerning that posting, you could also ask here.

Stefan
LaTeX.org admin
User avatar
Annabel
Posts: 14
Joined: Mon Jun 16, 2008 3:21 pm

Issue with custom quotations in typewrite font

Post by Annabel »

Thanks. The hyphenat package solved the issue at the expense of many warnings. To get rid of the underfull and overfull box messages I have tried "The LaTeX Font Catalogue" to look for alternative fonts I am still not able to change the font locally. The following code works, but I get a "Font shap 'OT1/fve/m/n' undefined using 'OT1/cmr/m/n' instead on input line 151.

Code: Select all

\newenvironment{NewText}
    {\begin{center}\begin{minipage}[h]{.9\textwidth}\noindent{\bf New text:}\fontfamily{fve}\fontsize{12pt}{12pt}\selectfont}
    {\end{minipage}\end{center}}
It gives a different font, but not the one I want. Loading a font package changes the font of the whole document (which is pretty logical actually, but not what is needed for custom quotations). How can I alter this
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Issue with custom quotations in typewrite font

Post by Stefan Kottwitz »

Is Bera Serif (fve) the font you want?
You need Cork encoding for it, that can be achieved by

Code: Select all

\usepackage[T1]{fontenc}
though that will be valid for the complete document. Nevertheless it's recommendable, but ensure that all other fonts are still working then. It's also possible to change the font encoding temporarily by

Code: Select all

\fontencoding{T1}\selectfont
but I would use T1 for the complete document and use T1 encoded fonts.

Stefan
LaTeX.org admin
User avatar
Annabel
Posts: 14
Joined: Mon Jun 16, 2008 3:21 pm

Issue with custom quotations in typewrite font

Post by Annabel »

Thanks a lot! The solution I have now works perfectly for writing letters to answer comments of submitted publications:

Code: Select all

\newenvironment{MyQuotation}
    {\begin{center}\begin{minipage}[h]{.9\textwidth}\noindent\it}
    {\end{minipage}\end{center}}

\newenvironment{QuoteNewText}
    {\begin{center}\begin{minipage}[h]{.9\textwidth}\noindent{\bf New text:}\fontfamily{fve}\fontsize{10pt}{10pt}\fontencoding{T1}\selectfont}
    {\end{minipage}\end{center}}
PS: also thanks for welcoming me ;)
Post Reply