latex logo size and alignment

1,133 views
Skip to first unread message

Andrea Cassioli

unread,
May 9, 2016, 10:53:33 AM5/9/16
to sphinx-users
Hi,
I am trying (with no success) to find out how to change the size and the alignment of the logo we pass via the `html_logo` option. Any suggestions?

Ian Bell

unread,
May 9, 2016, 10:32:59 PM5/9/16
to sphinx...@googlegroups.com
I had exactly the same problem.  Size-wise, your best bet is to just make the logo image itself quite small, such that it is always a good size.  Alignment is trickier.  I tried all the CSS tricks I could think of in the jinja layout files, but was never able to get it to work....

Ian

On Mon, May 9, 2016 at 5:24 AM, Andrea Cassioli <andrea....@mosek.com> wrote:
Hi,
I am trying (with no success) to find out how to change the size and the alignment of the logo we pass via the `html_logo` option. Any suggestions?

--
You received this message because you are subscribed to the Google Groups "sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
To post to this group, send email to sphinx...@googlegroups.com.
Visit this group at https://groups.google.com/group/sphinx-users.
For more options, visit https://groups.google.com/d/optout.

gilberto dos santos alves

unread,
May 10, 2016, 5:34:09 PM5/10/16
to sphinx...@googlegroups.com
please could you post more details. my first ideia is about what are format and size and other properties of you html_logo image.
regards.

2016-05-09 8:24 GMT-03:00 Andrea Cassioli <andrea....@mosek.com>:
Hi,
I am trying (with no success) to find out how to change the size and the alignment of the logo we pass via the `html_logo` option. Any suggestions?

--
You received this message because you are subscribed to the Google Groups "sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
To post to this group, send email to sphinx...@googlegroups.com.
Visit this group at https://groups.google.com/group/sphinx-users.
For more options, visit https://groups.google.com/d/optout.



--
gilberto dos santos alves
+55(11)9-8646-5049
sao paulo - sp - brasil




gilberto dos santos alves

unread,
May 10, 2016, 6:44:31 PM5/10/16
to sphinx...@googlegroups.com
please see [1] that say for HTML and LaTeX your image atributes must be pt (points) not pixels. take care about 1/72 for inch or centimeters this will make big differences on results.

[1] http://www.sphinx-doc.org/en/stable/rest.html#images

2016-05-09 8:24 GMT-03:00 Andrea Cassioli <andrea....@mosek.com>:
Hi,
I am trying (with no success) to find out how to change the size and the alignment of the logo we pass via the `html_logo` option. Any suggestions?

--
You received this message because you are subscribed to the Google Groups "sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
To post to this group, send email to sphinx...@googlegroups.com.
Visit this group at https://groups.google.com/group/sphinx-users.
For more options, visit https://groups.google.com/d/optout.

Andrea Cassioli

unread,
May 11, 2016, 5:27:40 PM5/11/16
to sphinx-users
Hi,
I am so sorry I have realised my post was wrong! In the title I said latex logo, while in the post I mentioned html logo...

Well the first is the correct one. I would like to change the `latex_logo` image size and alignment. Any suggestions?

gilberto dos santos alves

unread,
May 11, 2016, 9:47:33 PM5/11/16
to sphinx...@googlegroups.com
hi. please read what i posted and great chance that is what you want. regards.

--
You received this message because you are subscribed to the Google Groups "sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
To post to this group, send email to sphinx...@googlegroups.com.
Visit this group at https://groups.google.com/group/sphinx-users.
For more options, visit https://groups.google.com/d/optout.

Andrea Cassioli

unread,
May 12, 2016, 8:17:50 PM5/12/16
to sphinx-users
Hi @gsavix,

actually I do not think it helps. The pdf logo is specified in the conf.py passing the file name. But I cannot see how to change the image size and position...

gilberto dos santos alves

unread,
May 13, 2016, 1:20:47 PM5/13/16
to sphinx...@googlegroups.com
hi. have you dpi of your image, look at these atributes sphinx latex use this to build your final doc.

--
You received this message because you are subscribed to the Google Groups "sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
To post to this group, send email to sphinx...@googlegroups.com.
Visit this group at https://groups.google.com/group/sphinx-users.
For more options, visit https://groups.google.com/d/optout.

Peter Burdine

unread,
May 13, 2016, 8:17:55 PM5/13/16
to sphinx-users
Andrea,

I could not get the size changed easily without post processing.  The easiest way to get it to be the correct size coming out of sphinx is to give it as in input that is already the correct size.  Also be aware that if rendering on windows, if the input image has alpha channel data (eg a .png file) all the text on the page may show up in bold.  You can avoid this issue if you use a .jpg or a image editor that will remove that data.

As for the position, I approached it by creating my own sty file and then including that.  So in you preamble you would need to add
\usepackage{my_sty_file}

Then create an sty file, eg my_sty_file.sty.  This needs to get copied to your build/latex dir.  It will redefine what commands you want to modify.  For example, if you wanted remove the logo from the front page, you would redefine \maketitle.  The default is defined as:
\renewcommand{\maketitle}{%
  \begin{titlepage}%
    \let\footnotesize\small
    \let\footnoterule\relax
    \rule{\textwidth}{1pt}%
    \ifsphinxpdfoutput
      \begingroup
      % These \defs are required to deal with multi-line authors; it
      % changes \\ to ', ' (comma-space), making it pass muster for
      % generating document info in the PDF file.
      \def\\{, }
      \def\and{and }
      \pdfinfo{
        /Author (\@author)
        /Title (\@title)
      }
      \endgroup
    \fi
    \begin{flushright}%
      \sphinxlogo%
      {\rm\Huge\py@HeaderFamily \@title \par}%
      {\em\LARGE\py@HeaderFamily \py@release\releaseinfo \par}
      \vfill
      {\LARGE\py@HeaderFamily
        \begin{tabular}[t]{c}
          \@author
        \end{tabular}
        \par}
      \vfill\vfill
      {\large
       \@date \par
       \vfill
       \py@authoraddress \par
      }%
    \end{flushright}%\par
    \@thanks
  \end{titlepage}%
  \cleardoublepage%
  \setcounter{footnote}{0}%
  \let\thanks\relax\let\maketitle\relax
  %\gdef\@thanks{}\gdef\@author{}\gdef\@title{}
}

You can see in the above the \sphinxlogo% command.  If you don't want to logo on the front page/center, then you can comment it out or move it to a better location.

If you wanted it in the headers/footers, you could modify the header/footer definitions, for example:
\fancypagestyle{plain}{
    \fancyhead[L]{\sphinxlogo}
}
\fancypagestyle{normal}{
    \fancyhead[L]{\sphinxlogo}
}
\fancyhead{}
\fancyfoot{}

If the above were placed in your sty file, then it would put the logo in the upper left corner of the header (one page output, you need to modify it if you are using a 2 page layout).

I am convinced that getting sphinx to work correctly is about 80% learning LaTeX, then figuring out how to change the LaTeX command to make things work the way I want.  This is difficult because you need to figure out all of the styles the Sphinx applies by default and which rst commands map to which LaTeX commands.  I think the documentation about how to modify the PDF output is lacking, it has taken me a week or 2 of a lot of searching online to figure out to make documents look the way I want them.  I've found on more then one occasion people just post process the .tex file then convert it to a PDF because it is easier than trying to figure out how to make Sphinx do what they want.  Here is one example: https://github.com/jmcnamara/XlsxWriter/blob/master/dev/release/modify_latex.pl .  I've seen other places where they do the same thing to get tables centered since they default to left align.

Hope the above helps.

--Peter
Reply all
Reply to author
Forward
0 new messages