One author per line in latex output?

25 views
Skip to first unread message

Angel de Vicente

unread,
Mar 2, 2020, 9:58:05 AM3/2/20
to sphinx-users
Hi,

I would like to give in author variable (conf.py)  a list of authors, so that in the LaTeX output, each author is printed in a different line. I tried to Google for this and tried to put \\ etc. in the author string, but so far without any luck.

Is there any way to get this behaviour?

Many thanks,
Ángel de Vicente

Monir Bouhmidi

unread,
Mar 2, 2020, 10:02:48 AM3/2/20
to sphinx...@googlegroups.com
What do you mean?


--
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 view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/60bd9a63-7c99-4468-a6fa-0c39af543c85%40googlegroups.com.

Angel de Vicente

unread,
Mar 2, 2020, 10:10:56 AM3/2/20
to sphinx-users
Assume in conf.py  I have:

   author = 'John Smith \\ Michael Jackson'

After generating the latex output, and running latex to get the PDF file, I would just like that Jonh Smith and Michael Jackson are in different lines (right now all authors end up in just a single line in the PDF file, so if the author list is long, then it is not readable.

Thanks,

Message has been deleted

Komiya Takeshi

unread,
Mar 5, 2020, 8:16:27 AM3/5/20
to sphinx...@googlegroups.com
Hi,

How about using `latex_document`? It accepts LaTeX macros for authors.
https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-latex_documents

Thanks,
Takeshi KOMIYA

2020年3月2日(月) 23:58 Angel de Vicente <txib...@gmail.com>:

jfbu

unread,
Mar 5, 2020, 8:29:18 AM3/5/20
to sphinx...@googlegroups.com
Hi,

Maybe

https://github.com/matplotlib/matplotlib/pull/15799

will help you it gives a particular meaning to LaTeX's \and
(you need \\and in a Python string)
to get one author per line

Thanks,
Jean-François

Stefano David

unread,
Mar 8, 2020, 4:12:20 AM3/8/20
to sphinx-users
Hi,


On Monday, 2 March 2020 16:10:56 UTC+1, Angel de Vicente wrote:
Assume in conf.py  I have:

   author = 'John Smith \\ Michael Jackson'
As Jean-Francois already wrote, it should suffice to write 

author = 'John Smith \\and Michael Jackson \\and Angel de Vicente'

to have the result you desire. I can't test it right now, but I will in the next days. I just got a small project where this is a requirement, so I need to make it work as well :-)

Best regards,
Stefano

jfbu

unread,
Mar 8, 2020, 9:04:33 AM3/8/20
to sphinx...@googlegroups.com
Hi Stefano

when testing this you may also need to add the following definition of \and

latex_elements['preamble'] = r"""
% One line per author on title page
\DeclareRobustCommand{\and}%
{\end{tabular}\kern-\tabcolsep\\\begin{tabular}[t]{c}}%
"""

(this is the content of my matplotlib PR I linked to)
If not using this, then \and simply separates horizontally: this is
hard-coded in LaTeX source code for title page mark-up.

Using however the above redefinition I get a nice

John Smith
Michael Jackson
Angel de Vicente

in output on frontpage.

With LaTeX's \\ as in

'John Smith \\\\ Michael Jackson \\\\ Angel de Vicente',

or

r'John Smith \\ Michael Jackson \\ Angel de Vicente',


the names are centered around identical vertical
axis, it gives a bad ragged look, like this

John Smith
Michael Jackson
Angel de Vicente


And as Takeshi pointed out one should use the latex_documents config variable

latex_documents = [
('index',
'foo.tex',
'Test',
'John Smith \\and Michael Jackson \\and Angel de Vicente',
'manual')
]

Cheers,
Jean-François


Reply all
Reply to author
Forward
0 new messages