0

How do I define a new environment so that the text in it is all in small font, or in tiny font, say?

I have the example

\newenvironment{mysage}{\sageblock}{\endsageblock}

in mind, which usually has fixed-width output. (Yes, I still want fixed-width output, just in small font.)

I know about the commands \small an \tiny - I just wonder where to put them.

2
  • 4
    Welcome to TeX.SE! See my answer here: tex.stackexchange.com/questions/417711/… -- replace \rmfamily with \small, so \newenvironment{mysage}{\small\sageblock}{\endsageblock} should work
    – user31729
    Mar 2, 2018 at 15:45
  • @ChristianHupfer Not really: at least you need \par in front of \small.
    – egreg
    Mar 2, 2018 at 18:31

1 Answer 1

1

Since sageblock is based on verbatim of the homonymous package, you can do

\documentclass{article}
\usepackage{sagetex}
\usepackage{etoolbox}

\makeatletter
\newenvironment{mysage}
 {\preto\verbatim@font{\small}\sageblock}
 {\endsageblock}
\makeatother

\begin{document}

Abc def ghi
\begin{sageblock}
aaa bbb ccc
\end{sageblock}
Abc def ghi
\begin{mysage}
aaa bbb ccc
\end{mysage}
Abc def ghi

\end{document}

enter image description here

A naïve definition such as

\newenvironment{mysage}
 {\small\sageblock}
 {\endsageblock}

would not work.

3
  • Thanks for calling my proposition naïve ... I was just too lazy in order to look what \sageblock does
    – user31729
    Mar 2, 2018 at 20:55
  • Why wouldn't a naive definition work? It seems to work for me. Mar 3, 2018 at 22:54
  • @HAHelfgott If you don't have a blank line before the environment, the line spacing would go awry.
    – egreg
    Mar 3, 2018 at 23:16

You must log in to answer this question.

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