0

When I use overleaf by following code:

\usepackage{tocbasic}

\DeclareTOCStyleEntry[
  entrynumberformat=\entrynumberwithprefix{\figurename},
  dynnumwidth,
  numsep=1em
]{tocline}{figure}

\DeclareTOCStyleEntry[
  entrynumberformat=\entrynumberwithprefix{\tablename},
  dynnumwidth,
  numsep=1em
]{tocline}{table}
\newcommand\entrynumberwithprefix[2]{#1\enspace#2\hfill}

It generates : enter image description here

But when I used same code in TexStudio I got following errors:

enter image description here

How can I solve this problem for TexStudio?

EDIT

After first comment's code also , same error enter image description here

  • Your Error just says, that you are missing \begin{document} and \end{document}, which ist also missing in your Examplecode. DId you just forgot to add them? – DonFangzahn May 25 at 2:22
  • I have added them before \begin{document} in Overleaf and Texstudio. Doesnt work in Texstudio – Himal Acharya May 25 at 3:01
1
\newpage
\renewcommand{\baselinestretch}{1.5}
\newlength\figurelen
\settowidth\figurelen{Figure}
\renewcommand{\cftfigindent}{0em} 
\addtolength\cftfignumwidth{\figurelen}
\renewcommand\cftfigpresnum{Figure }
\addcontentsline{toc}{chapter}{\listfigurename}{ \listoffigures}

\newpage
\newlength\tablelen
\settowidth\tablelen{Table}
\renewcommand{\cfttabindent}{0em} 
\addtolength\cfttabnumwidth{\tablelen}
\renewcommand\cfttabpresnum{Table }
\addcontentsline{toc}{chapter}{\listtablename}{ \listoftables}
\newpage

Using this, it generates in TexStudio as described in question.

0

So, this is my MWE:

\documentclass[12pt,a4paper]{article}

\usepackage{tocbasic}

\DeclareTOCStyleEntry[
  entrynumberformat=\entrynumberwithprefix{\figurename},
  dynnumwidth,
  numsep=1em
]{tocline}{figure}

\DeclareTOCStyleEntry[
  entrynumberformat=\entrynumberwithprefix{\tablename},
  dynnumwidth,
  numsep=1em
]{tocline}{table}
\newcommand\entrynumberwithprefix[2]{#1\enspace#2\hfill}

\begin{document}

\begin{figure}
\begin{center}
\begin{tabular}{|c|c|}
\hline 
a & b \\ 
\hline 
c & d \\ 
\hline 
\end{tabular} 
\end{center}
\caption{Hi}
\end{figure}

\addcontentsline{toc}{chapter}{\listfigurename}
\listoffigures

\end{document}

The output is then:

enter image description here

Hope this helps.

  • I run same code in new Textsudio file same error generates – Himal Acharya May 25 at 3:46
  • 1
    @HimalAcharya - TeXstudio is just a front-end to a TeX distribution. Which TeX distribution is installed on your system? – Mico May 25 at 4:11
  • pdfTeX 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian) kpathsea version 6.2.1 – Himal Acharya May 25 at 4:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.