Document Classesmemoir | Chapter Number printed at low Resolution

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
leogas
Posts: 5
Joined: Tue Aug 02, 2011 11:20 am

memoir | Chapter Number printed at low Resolution

Post by leogas »

Hello,

I have a problem with the Memoir document class.
I created a document based on the file "daleif1-style.tex" generated by the Memoir tex file.

Here's the tex file:

Code: Select all

\documentclass{memoir}
%\let\STARTCODE\relax 
%\let\STOPCODE\relax 
%\STARTCODE
\usepackage{color,calc,graphicx,soul,fourier}
\definecolor{nicered}{rgb}{.647,.129,.149}
\makeatletter
\newlength\dlf@normtxtw
\setlength\dlf@normtxtw{\textwidth}
\def\myhelvetfont{\def\sfdefault{mdput}}
\newsavebox{\feline@chapter}
\newcommand\feline@chapter@marker[1][4cm]{%
  \sbox\feline@chapter{%
    \resizebox{!}{#1}{\fboxsep=1pt%
      \colorbox{nicered}{\color{white}\bfseries\sffamily\thechapter}%
    }}%
  \rotatebox{90}{%
    \resizebox{%
      \heightof{\usebox{\feline@chapter}}+\depthof{\usebox{\feline@chapter}}}%
    {!}{\scshape\so\@chapapp}}\quad%
  \raisebox{\depthof{\usebox{\feline@chapter}}}{\usebox{\feline@chapter}}%
}
\newcommand\feline@chm[1][4cm]{%
  \sbox\feline@chapter{\feline@chapter@marker[#1]}%
  \makebox[0pt][l]{% aka \rlap
    \makebox[1cm][r]{\usebox\feline@chapter}%
  }}
\makechapterstyle{daleif1}{
  \renewcommand\chapnamefont{\normalfont\Large\scshape\raggedleft\so}
  \renewcommand\chaptitlefont{\normalfont\huge\bfseries\scshape\color{nicered}}
  \renewcommand\chapternamenum{}
  \renewcommand\printchaptername{}
  \renewcommand\printchapternum{\null\hfill\feline@chm[2.5cm]\par}
  \renewcommand\afterchapternum{\par\vskip\midchapskip}
  \renewcommand\printchaptertitle[1]{\chaptitlefont\raggedleft ##1\par}
}
\makeatother
\chapterstyle{daleif1}
%\STOPCODE
\setlength\afterchapskip {\onelineskip }
\setlength\beforechapskip {\onelineskip }
\usepackage{lipsum}
\begin{document}
\chapter{Hello World!}
Hello World!!!
\end{document}

I have a problem with the generated pdf file (I'm a Windows 7 user, I use MikTeX 2.9, with pdfLaTeX compiler): the chapter number is printed at a very low resolution, it does not seem to be printed as a character (in vector graphics) but as a bitmap.

It looks very different with respect to the example provided in the Memoir manual (MemoirChapStyles.pdf).

Just to be clearer, here is the expected result, representing the chapter number as it is in the MemoirChapStyles.pdf file:
Chapter number, as it it in the MemoirChapStyles.pdf file
Chapter number, as it it in the MemoirChapStyles.pdf file
Good.png (10.13 KiB) Viewed 7231 times
And here is the one the that I get with MikTeX/pdfLaTeX:
Chapter number, as I get it with MikTeK/pdfLaTeX
Chapter number, as I get it with MikTeK/pdfLaTeX
Bad.png (9.98 KiB) Viewed 7231 times
With MikTeX/LaTeX, the generated DVI is different:
Chapter number, as I get it on the DVI generated with MikTeK\LaTeX
Chapter number, as I get it on the DVI generated with MikTeK\LaTeX
BadDVI.png (4.54 KiB) Viewed 7231 times
Does anyone have had the same problem before?
Do you have any idea of how to solve it?

Thank you in advance,

Leonardo
Last edited by leogas on Thu Aug 11, 2011 10:58 pm, edited 1 time in total.

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

Re: memoir | Chapter Number printed at low Resolution

Post by kaiserkarl13 »

If I download the first six files at http://www.ctan.org/tex-archive/fonts/f ... ex/fourier, I get the same result, but I also get a bunch of "symbol not found; defaults substituted" errors. This is the root cause of your problem (you don't have the fonts in the right sizes installed, at least not in the right way for LaTeX to find them).

If I download all 13 files in the above directory, however, it gives me a "Metric (TFM) file not found" error, which is further evidence that a font file is missing.

Find all the necessary files to use the Fourier fonts correctly and this problem may go away.
leogas
Posts: 5
Joined: Tue Aug 02, 2011 11:20 am

Re: memoir | Chapter Number printed at low Resolution

Post by leogas »

I already have all those files. Actually, MikTeX took care of everything.
In fact I don't get any error like the one you say, apart from a few "File <name>-style.* does not exist", but those are due to the "includegraphics" commands present in the source file.

The problem seems to be somewhere else.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

memoir | Chapter Number printed at low Resolution

Post by localghost »

Try to remedy this issue by enabling the right font encoding (in the preamble).

Code: Select all

\usepackage[T1]{fontenc}
Insert this line before loading a font package.


Thorsten
leogas
Posts: 5
Joined: Tue Aug 02, 2011 11:20 am

memoir | Chapter Number printed at low Resolution

Post by leogas »

Unfortunately, no results... :(
I think I'll use another style.

But let's try one more time:
I noticed that if I remove the "sffamily" command in the definition of the box for the chapter number, the problem disappears (but the result does not look as good as in the memoir documentation with the sffamily font).

Here the original code:

Code: Select all

\colorbox{nicered}{\color{white}\bfseries\sffamily\color{blue}\thechapter}%
Here is how I modified it.

Code: Select all

\colorbox{nicered}{\color{white}\bfseries\color{blue}\thechapter}%
What does this mean? The Sans serif family should be defined in my system...

Leonardo
Montag
Posts: 340
Joined: Wed Jul 15, 2009 9:25 am

memoir | Chapter Number printed at low Resolution

Post by Montag »

It's now probably overdue: Please provide us with an MWE, as it is mentioned in section 3 of the rules. :)
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1
leogas
Posts: 5
Joined: Tue Aug 02, 2011 11:20 am

memoir | Chapter Number printed at low Resolution

Post by leogas »

Ok,

so here's the code that generates the low resolution chapter number:

Code: Select all

\documentclass{memoir}
\usepackage[T1]{fontenc}
\usepackage{color,calc,graphicx,soul,fourier}
\definecolor{nicered}{rgb}{.647,.129,.149}
\makeatletter
\newlength\dlf@normtxtw
\setlength\dlf@normtxtw{\textwidth}
\def\myhelvetfont{\def\sfdefault{mdput}}
\newsavebox{\feline@chapter}
\newcommand\feline@chapter@marker[1][4cm]{%
  \sbox\feline@chapter{%
    \resizebox{!}{#1}{\fboxsep=1pt%
      \colorbox{nicered}{\color{white}\bfseries\sffamily\thechapter}%
    }}%
  \rotatebox{90}{%
    \resizebox{%
      \heightof{\usebox{\feline@chapter}}+\depthof{\usebox{\feline@chapter}}}%
    {!}{\scshape\so\@chapapp}}\quad%
  \raisebox{\depthof{\usebox{\feline@chapter}}}{\usebox{\feline@chapter}}%
}
\newcommand\feline@chm[1][4cm]{%
  \sbox\feline@chapter{\feline@chapter@marker[#1]}%
  \makebox[0pt][l]{% aka \rlap
    \makebox[1cm][r]{\usebox\feline@chapter}%
  }}
\makechapterstyle{daleif1}{
  \renewcommand\chapnamefont{\normalfont\Large\scshape\raggedleft\so}
  \renewcommand\chaptitlefont{\normalfont\huge\bfseries\scshape\color{nicered}}
  \renewcommand\chapternamenum{}
  \renewcommand\printchaptername{}
  \renewcommand\printchapternum{\null\hfill\feline@chm[2.5cm]\par}
  \renewcommand\afterchapternum{\par\vskip\midchapskip}
  \renewcommand\printchaptertitle[1]{\chaptitlefont\raggedleft ##1\par}
}
\makeatother
\chapterstyle{daleif1}
\setlength\afterchapskip {\onelineskip }
\setlength\beforechapskip {\onelineskip }
\usepackage{lipsum}
\begin{document}
\chapter{A chapter title}
Hello World!!!
\end{document}
And here's the other version, which looks better in terms of resolution, but does not look as good in terms of font style:

Code: Select all

\documentclass{memoir}
\usepackage[T1]{fontenc}
\usepackage{color,calc,graphicx,soul,fourier}
\definecolor{nicered}{rgb}{.647,.129,.149}
\makeatletter
\newlength\dlf@normtxtw
\setlength\dlf@normtxtw{\textwidth}
\def\myhelvetfont{\def\sfdefault{mdput}}
\newsavebox{\feline@chapter}
\newcommand\feline@chapter@marker[1][4cm]{%
  \sbox\feline@chapter{%
    \resizebox{!}{#1}{\fboxsep=1pt%
      \colorbox{nicered}{\color{white}\bfseries\thechapter}%
    }}%
  \rotatebox{90}{%
    \resizebox{%
      \heightof{\usebox{\feline@chapter}}+\depthof{\usebox{\feline@chapter}}}%
    {!}{\scshape\so\@chapapp}}\quad%
  \raisebox{\depthof{\usebox{\feline@chapter}}}{\usebox{\feline@chapter}}%
}
\newcommand\feline@chm[1][4cm]{%
  \sbox\feline@chapter{\feline@chapter@marker[#1]}%
  \makebox[0pt][l]{% aka \rlap
    \makebox[1cm][r]{\usebox\feline@chapter}%
  }}
\makechapterstyle{daleif1}{
  \renewcommand\chapnamefont{\normalfont\Large\scshape\raggedleft\so}
  \renewcommand\chaptitlefont{\normalfont\huge\bfseries\scshape\color{nicered}}
  \renewcommand\chapternamenum{}
  \renewcommand\printchaptername{}
  \renewcommand\printchapternum{\null\hfill\feline@chm[2.5cm]\par}
  \renewcommand\afterchapternum{\par\vskip\midchapskip}
  \renewcommand\printchaptertitle[1]{\chaptitlefont\raggedleft ##1\par}
}
\makeatother
\chapterstyle{daleif1}
\setlength\afterchapskip {\onelineskip }
\setlength\beforechapskip {\onelineskip }
\usepackage{lipsum}
\begin{document}
\chapter{A chapter title}
Hello World!!!
\end{document}
Please notice that the codes are the very same, except for a \sffamily which is present in the first code but not on the second one.
Actually, the problem persists if you replace that \sffamily with \ttfamily...

Any ideas regarding possible solutions?

Thank you in advance,

Leonardo
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

memoir | Chapter Number printed at low Resolution

Post by frabjous »

When I compile your sample (with TeXlive 2011 on Linux), the 1 looks nice. Again, the problem would seem to be with the fonts installed on your system.

That 1 looks like it's just computer modern sans serif.

Do you have the cm-super package installed, for type 1 CM fonts?

Have you tried loading it, or alternatively, lmodern before loading fourier?

Code: Select all

\usepackage{lmodern}
(right before the other \usepackage line)

There's a funny line in the code:

Code: Select all

\def\myhelvetfont{\def\sfdefault{mdput}}
This line doesn't actually do anything, because it defines a command, which is then not used later on. But if the command \myhelvetfont were used, what it would do is change the sans serif (sffamily) font to Utopia. (Which is particularly strange, since the name of the command would suggest Helvetica!) Try it, put \myhelvetfont on the line right after the definition, and the look of the 1 changes. You can also try different values for \sfdefault. Put in:

Code: Select all

\renewcommand*{\sfdefault}{phv}
for Helvetica. Again, the look of the 1 changes.

Whats fonts does your PDF viewer say are embedded?

But if you want it to look like it looks in your first screen shot, you need Computer Modern or Latin Modern Sans Serif, and you'll need to make sure you have them installed as scaleable fonts. (cm-super or lmodern packages).
leogas
Posts: 5
Joined: Tue Aug 02, 2011 11:20 am

memoir | Chapter Number printed at low Resolution

Post by leogas »

Wow! It works!

I already had the cm-super installed.
So I added:

Code: Select all

\usepackage{lmodern}
at the very beginning... and the problem was solved!

Thank you very much for your help!!!
So, here's the final (working) code:

Code: Select all

\documentclass{memoir}
\usepackage{lmodern}
\usepackage{color,calc,graphicx,soul,fourier}
\definecolor{nicered}{rgb}{.647,.129,.149}
\makeatletter
\newlength\dlf@normtxtw
\setlength\dlf@normtxtw{\textwidth}
\def\myhelvetfont{\def\sfdefault{mdput}}
\newsavebox{\feline@chapter}
\newcommand\feline@chapter@marker[1][4cm]{%
  \sbox\feline@chapter{%
    \resizebox{!}{#1}{\fboxsep=1pt%
      \colorbox{nicered}{\color{white}\bfseries\sffamily\thechapter}%
    }}%
  \rotatebox{90}{%
    \resizebox{%
      \heightof{\usebox{\feline@chapter}}+\depthof{\usebox{\feline@chapter}}}%
    {!}{\scshape\so\@chapapp}}\quad%
  \raisebox{\depthof{\usebox{\feline@chapter}}}{\usebox{\feline@chapter}}%
}
\newcommand\feline@chm[1][4cm]{%
  \sbox\feline@chapter{\feline@chapter@marker[#1]}%
  \makebox[0pt][l]{% aka \rlap
    \makebox[1cm][r]{\usebox\feline@chapter}%
  }}
\makechapterstyle{daleif1}{
  \renewcommand\chapnamefont{\normalfont\Large\scshape\raggedleft\so}
  \renewcommand\chaptitlefont{\normalfont\huge\bfseries\scshape\color{nicered}}
  \renewcommand\chapternamenum{}
  \renewcommand\printchaptername{}
  \renewcommand\printchapternum{\null\hfill\feline@chm[2.5cm]\par}
  \renewcommand\afterchapternum{\par\vskip\midchapskip}
  \renewcommand\printchaptertitle[1]{\chaptitlefont\raggedleft ##1\par}
}
\makeatother
\chapterstyle{daleif1}
\setlength\afterchapskip {\onelineskip }
\setlength\beforechapskip {\onelineskip }
\usepackage{lipsum}
\begin{document}
\chapter{A chapter title}
Hello World!!!
\end{document}
Then, I didn't quite get the \myhelvetfont thing... I tried to put it right after the definition of \myhelvetfont but things did not change.
Things changed when I added:

Code: Select all

\renewcommand*{\sfdefault}{phv}
In this case, the "1" is different.

Thank you again!

Leonardo
Post Reply