0

in Getting length as number? I've seen a way to find out the length of \textwidth.

However, when instead using for example \getlength{hey} I receive an error. That occurred when using the code of all possible answers.

I'd actually like to go even further and obtain the length of something like | {\footnotesize hey}

this is an image

Did I miss something unusually simple or is it just a standard beginner Latex problem?

UPDATE: I'd like to obtain the lengths in point as a return. Or any other small metric like sp. So say the length of | {\footnotesize hey} was equivalent to X pt I'd like to see X pt returned in the documents' PDF.

UPDATE2: Here is an example code of what I would like to use the received length for in this specific case; sorry for the inconvenience so far! Hope this clears up things.

\documentclass[a4paper,10pt]{article}

\usepackage[backend=biber, style=alphabetic, isbn=true, url=true, doi=true]{biblatex}

\usepackage{multirow}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\setlength{\tabcolsep}{7pt}

\usepackage{calc}


\begin{document}

\begin{tabular}{ R{107pt} | L{278pt} | }

Something
    & Something else \\
    & Something else \\
    & \begin{tabular}{ @{}l l L{\widthof{| some other text}} | }
            Some & thing & {| some text} \\
            Some & thing & {| some other text} \\
      \end{tabular} \\

\end{tabular}

\end{document}

This is what I'd like to receive: enter image description here

10
  • You want \newlength{\mylength} in the preamble and then \settowidth{\mylength}{hey}\getlength{\mylength} in your document. Commented Dec 29, 2020 at 21:16
  • latex has a standard command \settowidth which appears to be what you are looking for, Commented Dec 29, 2020 at 21:20
  • Hey thank you both! As far as I have seen and now also tried, this approach only works if I would want to set the length of a function variable to that length of | {\footnotesize hey}. I added an update to clarify :) Edit: for the purpose of what you meant (I guess) I'm currently using the package calc and command \widthof.
    – Tork
    Commented Dec 29, 2020 at 21:45
  • Your question is not at all clear but you can save the length from \settolength in a length command and then use it anywhere a length can be used. Or as you say there is \widthof from calc (which is essentially the same thing, but hiding the internal length) Commented Dec 29, 2020 at 21:59
  • \newlength\zzz \settolength\zzz{| {\footnotesize hey}} the length is \the\zzz Commented Dec 29, 2020 at 22:00

1 Answer 1

2

As far as I can tell you are looking for \settowidth

enter image description here

\documentclass{article}

\usepackage[T1]{fontenc}

\newlength\zzz
\begin{document}

[hey]

\settowidth\zzz{hey}

[\hspace{\zzz}] (\the\zzz)

\bigskip

[| {\footnotesize hey}]

\settowidth\zzz{| {\footnotesize hey}}

[\hspace{\zzz}] (\the\zzz)

\end{document}
2
  • Thanks that what I needed! The package apparently sets another font which I guess changes the length of {\footnotesize hey} relative to another font? Any work around for this happening? (I've just always been using the standard font until now)
    – Tork
    Commented Dec 30, 2020 at 10:57
  • @Tork really it is impossible to guess your issue if you continue to supply no example code. If you want to ask about font sizes, ask a new question with a new title and a new complete example document that shows the issue. Commented Dec 30, 2020 at 11:19

You must log in to answer this question.

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