Generaltabbing or font size

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Tie
Posts: 9
Joined: Tue Dec 22, 2009 4:10 pm

tabbing or font size

Post by Tie »

Hello all,

This question puzzles me a lot... I am trying to print something like that with indents on the left:

=INDEX(List,
.......SMALL(IF(MATCH(List,List,0)
..................=ROW(INDIRECT(”1:”&ROWS(List))),
................MATCH(List,List,0),
................””),
.......ROW(INDIRECT(”1:”&SUM(SIGN(MATCH(List,List,0)
....................................=ROW(INDIRECT(”1:”&ROWS(List)))))))))

(Please replace .... by blank)

With indents on the left, the levels of the functions are more visible. At the moment I use \begin{tabbing} , \end{tabbing} , \= , \> ... to realize that.

However, one problem is that the lines are too long, and they exceed the margin. I want to make the font smaller to fit the length of line, but it seems that {tabbing} can not do that...

So i guess, either i use something else than {tabbing} to realize indents or make the font smaller... But i do not know neither of these ways... Does anyone have any idea?

Thanks and regards

Tie

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

tabbing or font size

Post by localghost »

Use the listings package as shown in the code below.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage[includeheadfoot,margin=2cm]{geometry}
\usepackage[svgnames]{xcolor}
\usepackage{listings}
\usepackage{lmodern}

\lstset{
  aboveskip=1ex,
  backgroundcolor=\color{gray!25},
  basicstyle=\small\ttfamily,
  belowskip=1ex,
  breaklines=true,
  columns=fullflexible,
  framerule=0pt,
  framexrightmargin=0em,
  framexleftmargin=0em,
  numbers=left,
  numberstyle=\footnotesize\sffamily,
  tabsize=2
}

\begin{document}
\begin{lstlisting}
=INDEX(List,
       SMALL(IF(MATCH(List,List,0)
                  =ROW(INDIRECT("1:"&ROWS(List))),
                MATCH(List,List,0),
                ""),
       ROW(INDIRECT("1:"&SUM(SIGN(MATCH(List,List,0)
                                    =ROW(INDIRECT("1:"&ROWS(List)))))))))
\end{lstlisting}
\end{document}
For further information see the package manual.


Best regards and welcome to the board
Thorsten
Tie
Posts: 9
Joined: Tue Dec 22, 2009 4:10 pm

Re: tabbing or font size

Post by Tie »

Hi localghost,

Thanks very much for your code!

I have already made your code run inside my code, and i see the interest of using listings. However, the "intend" does not work 100% yet.

When I set "showspaces=true, tabsize=1", the printed output is exactly intended as my code, which is good; However, if I set "showspaces=false, tabsize=1", the position of each line changes a little bit.

Obviously I do not want to show spaces finally, do you see how to do to make printed lines intended as the code?

Thanks and regards

Tie CHENG
Tie
Posts: 9
Joined: Tue Dec 22, 2009 4:10 pm

tabbing or font size

Post by Tie »

Got it, we need to set lstset

keepspaces=true,


Regards

Tie CHENG
Post Reply