How it is possible to convert LaTeX document to Word (docx file) with all cross-references and labels for images and equations, tables by Pandoc? - latex

I have a tex-file obtained originally from RStudio with bookdown. The original set of Rmd-files were deleted by accident.
So I need to convert below minimized correct tex-file to Word (docx file extension):
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
]{article}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\#ifundefined{KOMAClassName}{% if non-KOMA class
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
\KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
pdftitle={Simple document},
hidelinks,
pdfcreator={LaTeX via pandoc}}
\urlstyle{same} % disable monospaced font for URLs
\usepackage[margin=1in]{geometry}
\usepackage{longtable,booktabs,array}
\usepackage{calc} % for calculating minipage widths
% Correct order of tables after \paragraph or \subparagraph
\usepackage{etoolbox}
\makeatletter
\patchcmd\longtable{\par}{\if#noskipsec\mbox{}\fi\par}{}{}
\makeatother
% Allow footnotes in longtable head/foot
\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
\makesavenoteenv{longtable}
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin#nat#width>\linewidth\linewidth\else\Gin#nat#width\fi}
\def\maxheight{\ifdim\Gin#nat#height>\textheight\textheight\else\Gin#nat#height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Set default figure placement to htbp
\makeatletter
\def\fps#figure{htbp}
\makeatother
\usepackage[normalem]{ulem}
% Avoid problems with \sout in headers with hyperref
\pdfstringdefDisableCommands{\renewcommand{\sout}{}}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{5}
\ifLuaTeX
\usepackage{selnolig} % disable illegal ligatures
\fi
\usepackage[]{biblatex}
\addbibresource{bibliography.bib}
\title{Simple document}
\author{}
\date{\vspace{-2.5em}}
\usepackage{amsthm}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}{Lemma}[section]
\newtheorem{corollary}{Corollary}[section]
\newtheorem{proposition}{Proposition}[section]
\newtheorem{conjecture}{Conjecture}[section]
\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]
\theoremstyle{definition}
\newtheorem{example}{Example}[section]
\theoremstyle{definition}
\newtheorem{exercise}{Exercise}[section]
\theoremstyle{remark}
\newtheorem*{remark}{Remark}
\newtheorem*{solution}{Solution}
\begin{document}
\maketitle
{
\setcounter{tocdepth}{2}
\tableofcontents
}
\hypertarget{format}{%
\section{Format}\label{format}}
Read \ref{format} for details.
Or read \protect\hyperlink{format}{format}.
Formatting:
\begin{itemize}
\tightlist
\item
sup-script or power - x\textsuperscript{2} ;
\item
sub-script - y\textsubscript{3} ;
\item
strike through - \sout{strike through} ;
\item
term -- definition ;
\item
long term --- long definition .
\end{itemize}
Here comes \textbf{footnote} \footnote{Footnote text} with its contents.
Image with caption, see \ref{fig:image}.
\begin{figure}
\centering
\includegraphics{image.png}
\caption{\label{fig:image} Image}
\end{figure}
Labeled table is below, see table \ref{tab:table}.
\begin{longtable}[]{#{}ll#{}}
\caption{\label{tab:table}\\
My table}\tabularnewline
\toprule
\textbf{Col 1 header} & \textbf{Col 2 header} \\
\midrule
\endfirsthead
\endhead
r1c1 & r1c2 \\
r2c1 & r2c2 \\
\bottomrule
\end{longtable}
Inline: \(a^2 + b^2 = c^2\).
Block:
\[ E = \frac{mc^2}{\sqrt{1-\frac{v^2}{c^2}}} \]
Labeled, see \eqref{eq:eq}:
\begin{equation}
f\left(k\right) =\binom{n}{k} p^k\left(1-p\right)^{n k}
\label{eq:eq}
\end{equation}
See LaTeX \autocite{latex} site for details.
Code is below, see \ref{exm:code}:
\begin{example}
\protect\hypertarget{exm:code}{}{\label{exm:code} }Hello world
\end{example}
\begin{verbatim}
int main(){
return 0;
}
\end{verbatim}
\hypertarget{references}{%
\section*{References}\label{references}}
\addcontentsline{toc}{section}{References}
\printbibliography
\end{document}
When I try to convert it to docx using pandoc (2.16.1 version) command below:
pandoc simple.tex --to docx+native_numbering --output simple.docx --table-of-contents --toc-depth 5 --number-sections --citeproc --verbose --csl ieee.csl
(In the above command ieee.csl was downloaded from Zotero).
I get
and I see many strange things:
[fig:image] along with Figure with number;
[tab:table] along with Table with number;
[eq:eq] instead of equation number;
[exm:code] instead of example number.
Is it possible to replace (or suppress them for Figure and Table) above strange […] fields by correct numbers and links using Pandoc to get correct docx output?

This is currently not supported by plain pandoc, but you can use filters to get the numbering back. E.g., the resolve-references.lua filter in the OpenJournals "Inara" project does something comparable. You may have to adjust and extend it to fully suit your requirements.

Related

VS code LaTex workshop book compile problem

Hi I'm new to LaTex and doing some translating at school in LaTex. Since I'm translating a book, I received a bulky file and when I tried to build it. It didn't work.. By the way I'm using TexLive and Visual Studio Code for editing.
The error consists of a lot of undefined sequences..
The code mainly operates with 3 files. modern_robotics.tex, mr1.tex and mr2.tex.
Due to copyright reasons and also the big file, I won't be able to upload all the codes. But I think I can upload the three files mentioned above. I think most of the problem is in mr2.. but I'm not sure.
Any help would be appreciated. Thanks.
modern_robotics.tex
\input{mr1}
% to center the book horizontally:
\setlength{\oddsidemargin}{63pt}
\setlength{\evensidemargin}{63pt}
% instead of centering horizontally, make it so pages can be enlarged in 2per printing without large gutter:
%\setlength{\oddsidemargin}{80pt}
%\setlength{\evensidemargin}{46pt}
\input{mr2}
mr1.tex
\documentclass[10pt]{book}
%======================================================================%
% PACKAGES %
%======================================================================%
\usepackage[centertags]{amsmath}
\usepackage{amsthm,amsfonts,amssymb,enumerate} % Amstex
%\usepackage{Jtocinc}% Jtocinc.sty Include Table of Contents as first entry
%\usepackage{fancybox}
\usepackage{makeidx}
\makeindex
\usepackage[shortlabels]{enumitem}
\usepackage{color}
\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{rotating}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{xspace}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{ifthen,version}
\usepackage{cancel}
\usepackage{arydshln}
\usepackage{mathtools}
\usepackage{booktabs}
\usepackage{xcolor}
\usepackage{framed}
\definecolor{shadecolor}{rgb}{0.9,0.9,0.9}
% For translation!!!!!!!!
\usepackage{kotex}
\usepackage{titlesec}
\titleformat{\chapter}% reformat chapter headings
[hang]% like section, with number on same line
{\Huge\bfseries}% formatting applied to whole
{\thechapter~장.}% Chapter number
{0.5em}% space between # and title
{}% formatting applied just to title
\titlespacing*{\chapter}{0pt}{-5mm}{20mm}
\titlespacing*{\section}{0pt}{15mm}{15mm}
\titlespacing*{\subsection}{0pt}{15mm}{15mm}
\titlespacing*{\subsubsection}{0pt}{15mm}{15mm}
\renewcommand{\figurename}{그림}
\usepackage{geometry}
\geometry{
a4paper,
left=20mm,
right=31mm,
top=40mm,
bottom=40mm
}
\usepackage[font={footnotesize,stretch=1.6}]{caption}
\setlength{\belowcaptionskip}{15mm}
\usepackage{setspace}
\setstretch{1.6}
\setlength\parindent{0pt}
% For translation!!!!!!!!
%%%%%%%%%%% for long sub-figures (160824) %%%%%%%%
\usepackage{caption}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{csquotes}
\usepackage[linktoc=all,colorlinks=true,urlcolor=blue]{hyperref}
\hypersetup{
colorlinks,
linkcolor=blue
}
\newboolean{include-notes}
% Comment out the following line to exclude the notes.
\setboolean{include-notes}{false}
%notes
\newcommand{\fpnote}[1]{\ifthenelse{\boolean{include-notes}}%
{\textbf{FP says: #1}}{}}
\newcommand{\klnote}[1]{\ifthenelse{\boolean{include-notes}}%
{\textbf{KL says: #1}}{}}
\newcommand{\kldraft}[1]{\ifthenelse{\boolean{include-notes}}%
{#1}{}}
\newenvironment{function}[2]
{
\vspace*{0.1in}
\noindent
\verb~#1~
\\
\noindent
#2
}{}
\usepackage{draftcopy}
\usepackage{fancyhdr}
\usepackage{datetime}
\begin{comment}
\usepackage[linktoc=all]{hyperref}
\hypersetup{
colorlinks,
linkcolor=blue
}
\end{comment}
% Visual ornaments
% \usepackage[avantgarde]{quotchap}
% select Sanserif font for title and quote
% \renewcommand\sectfont{\sffamily\bfseries\Huge}
% San serif section headers
\usepackage{sfsect}
% hyperref package should be the last one in \usepackage list
% \usepackage[colorlinks,backref]{hyperref}
%********** Fine Tune for this TeX
\hfuzz2pt % Don't bother to report over-full boxes if over-edge is < 2pt
\hyphenation{di-men-sion-al}
%\renewcommand{\theenumi}{\roman{enumi}}
%\renewcommand{\labelenumi}{{\normalfont(\theenumi)}}
\renewcommand{\theenumi}{\alph{enumi}}
\renewcommand{\labelenumi}{{\normalfont(\theenumi)}}
%======================================================================%
% COMMANDS %
%======================================================================%
%\renewcommand{\baselinestretch}{1.5}
%\renewcommand{\baselinestretch}{1.0}
% new commands for unit axes vectors
\newcommand{\xhat}{\ensuremath{\hat{\text{x}}}}
\newcommand{\yhat}{\ensuremath{\hat{\text{y}}}}
\newcommand{\zhat}{\ensuremath{\hat{\text{z}}}}
\newcommand{\Xhat}{\ensuremath{\hat{\text{X}}}}
\newcommand{\Yhat}{\ensuremath{\hat{\text{Y}}}}
\newcommand{\Zhat}{\ensuremath{\hat{\text{Z}}}}
\newcommand{\xhats}{\ensuremath{\hat{\text{x}}_{\text{s}}}}
\newcommand{\yhats}{\ensuremath{\hat{\text{y}}_{\text{s}}}}
\newcommand{\zhats}{\ensuremath{\hat{\text{z}}_{\text{s}}}}
\newcommand{\xhatb}{\ensuremath{\hat{\text{x}}_{\text{b}}}}
\newcommand{\yhatb}{\ensuremath{\hat{\text{y}}_{\text{b}}}}
\newcommand{\zhatb}{\ensuremath{\hat{\text{z}}_{\text{b}}}}
\newcommand{\xhatc}{\ensuremath{\hat{\text{x}}_{\text{c}}}}
\newcommand{\yhatc}{\ensuremath{\hat{\text{y}}_{\text{c}}}}
\newcommand{\zhatc}{\ensuremath{\hat{\text{z}}_{\text{c}}}}
% new commands for abstract (unrepresented) vectors
\newcommand{\vecp}{\ensuremath{\text{p}}}
\newcommand{\vecq}{\ensuremath{\text{q}}}
\newcommand{\vecr}{\ensuremath{\text{r}}}
\newcommand{\vecs}{\ensuremath{\text{s}}}
\newcommand{\vect}{\ensuremath{\text{t}}}
\newcommand{\vecu}{\ensuremath{\text{u}}}
\newcommand{\vecv}{\ensuremath{\text{v}}}
\newcommand{\vecw}{\ensuremath{\text{w}}}
\newcommand{\vecx}{\ensuremath{\text{x}}}
\newcommand{\vecy}{\ensuremath{\text{y}}}
\newcommand{\vecz}{\ensuremath{\text{z}}}
% new commands for orthogonal group
\newcommand{\SOthree}{\ensuremath{SO(3)}\xspace}
\newcommand{\SOtwo}{\ensuremath{SO(2)}\xspace}
\newcommand{\SOn}{\ensuremath{SO(n)}\xspace}
\newcommand{\sothree}{\ensuremath{so(3)}\xspace}
\newcommand{\sotwo}{\ensuremath{so(2)}\xspace}
\newcommand{\son}{\ensuremath{so(n)}\xspace}
\newcommand{\SE}{\ensuremath{SE(3)}\xspace}
\newcommand{\se}{\ensuremath{se(3)}\xspace}
% new commands for bold face greeks
\newcommand{\bomega}{\ensuremath{\mathbf{\omega}}}
\newcommand{\blambda}{\ensuremath{\mathbf{\lambda}}}
% new commands for mathematical equations
\newcommand{\defeq}{\ensuremath{\triangleq}}
\newcommand{\trans}{\ensuremath{^{\mbox{\scriptsize $\top$}}}}
\newcommand{\invtrans}{\ensuremath{^{\mbox{\scriptsize $-\top$}}}}
\newcommand{\inverse}{\ensuremath{^{\mbox{\scriptsize -1}}}}
\newcommand{\smallTH}{\ensuremath{^{\mbox{\scriptsize th}}}}
\newcommand{\trace}{\ensuremath{\mathrm{tr}}}
\newcommand{\RE}{\ensuremath{\mathbb{R}}}
\newcommand{\strad}{\bar{}\!\!\!\!\:d}
\newcommand{\bstrad}{\,\,\,\bar{}\!\!\!\!\:d}
\newcommand{\xinit}{\ensuremath{x^{\circ}}}
\newcommand{\optimal}{\ensuremath{^{\mbox{\scriptsize \textsf {OPT}}}}}
% new commands for abbreviations and others
\newcommand{\etal}{\textit{et al.}\#\xspace}
\newcommand{\eg}{\textit{e.g.,}\xspace}
\newcommand{\ie}{\textit{i.e.,}\xspace}
\newcommand{\etc}{\textit{etc}\#\xspace}
%\newcommand{\mass}{\mathfrak{m}}
%\newcommand{\gravity}{\mathfrak{g}}
% Zero height rule of width of one quad
\newcommand{\IR}[1]{\rule{1em}{0pt}%
\makebox[0cm][c]{\rotatebox{45}{\ #1}}}
%********** Definitions for proof
\def\QED{\mbox{\rule[0pt]{1.5ex}{1.5ex}}}
\def\endofrmk{\hspace*{\fill}~$\Diamond$\par\endtrivlist\unskip}
%********** Environments
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{명제}
%
\theoremstyle{definition}
\newtheorem{definition}{정의}[chapter]
\newtheorem{assumption}{Assumption}[chapter]
\newtheorem{condition}{Condition}[chapter]
\newtheorem{example}{예제}[chapter]
%
%
\numberwithin{equation}{chapter}
%\renewcommand{\theequation}{\thesection.\arabic{equation}}
%********** Tools
\newcommand{\mnote}[1]%
{\mbox{}\marginpar{\raggedright\hspace{0pt}\small#1}}
% {\footnote{#1}}
%\reversemarginpar
\newcommand {\nemo} {\hfill $\Box$ }
\newlength{\blenfbox}
\newsavebox{\boxff}
\newenvironment{FramedPar}%
{\setlength{\fboxsep}{15pt}%
\setlength{\blenfbox}{\fboxsep}%
\addtolength{\blenfbox}{\fboxrule}%
\begin{lrbox}{\boxff}
\minipage{\textwidth}}%
{\endminipage\end{lrbox}
\bigskip\noindent\hspace*{-\blenfbox}%
\fbox{\usebox{\boxff}}\bigskip\bigskip}
\newlength{\mylength}
\newenvironment{FramedNM}%
{\setlength{\fboxsep}{5pt}%
\setlength{\mylength}{\fboxsep}%
\addtolength{\mylength}{\fboxrule}%
\Sbox
\minipage{\textwidth}%
\setlength{\abovedisplayskip}{0pt}}%
{\endminipage\endSbox\par
\addvspace{\smallskipamount}\noindent\hspace*{-\mylength}%
\fbox{\TheSbox}\smallskip}
\newenvironment{FramedEqn}%
{\setlength{\fboxsep}{15pt}
\setlength{\mylength}{\linewidth}%
\addtolength{\mylength}{-2\fboxsep}%
\addtolength{\mylength}{-2\fboxrule}%
\Sbox
\minipage{\mylength}%
\setlength{\abovedisplayskip}{0pt}%
\setlength{\belowdisplayskip}{0pt}%
\equation}%
{\endequation\endminipage\endSbox
\[\fbox{\TheSbox}\]}
\newcounter{xmplctr}
\newcounter{rmrkctr}
\newenvironment{remark}{
\addtocounter{rmrkctr}{1}
\begin{trivlist}
\item[] {\bf Remark \thermrkctr}
}{\end{trivlist}}
%\setlength{\textheight}{7.5in} % fit to b5
%\setlength{\textwidth}{5.5in} % fit to b5
%\setlength{\oddsidemargin}{0.5in}
%\setlength{\evensidemargin}{0.5in}
%\setlength{\footskip}{20mm} % fit to b5
\raggedbottom
%======================================================================%
% COMMANDS FROM KEVIN %
%======================================================================%
% to make the book: pdflatex; bibtex; pdflatex; pdflatex; makeindex; pdflatex
\usepackage{verbatim}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Indexing. See http://en.wikibooks.org/wiki/LaTeX/Indexing
%
% usual method when defining a term is {\bf term}\index{indexed form of term}
% if we want it to appear in the index as
%
% joint
% revolute, 13
%
% then use {\bf revolute joint}\index{joint|revolute}
%
% can also use \indbf{term} for bold indexed term or \ind{term} for indexed term as short hand if printed
% form is same way it should show up in index
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\topfraction}{0.99}
\renewcommand{\textfraction}{0.01}
\renewcommand{\floatpagefraction}{0.95}
\renewcommand{\textfloatsep}{6mm}
\providecommand{\ind}[1]{#1\index{#1}}
\providecommand{\indbf}[1]{{\bf #1}\index{#1}}
\DeclareGraphicsExtensions{.jpg,.pdf,.mps,.png,.eps} %For pdftex
\newcommand{\real}{\mathbb{R}}
\renewcommand{\Re}{\mathbb{R}} % redefine script R
%\newenvironment{flushenum}{
%\begin{enumerate}
% \setlength{\leftmargin}{0pt}
%}{\end{enumerate}}
\setcounter{secnumdepth}{3}
\newcounter{exercise}[chapter]
\newcommand{\exercise}{\refstepcounter{exercise} \vspace*{5mm} \noindent {\bf \theexercise. }}
\newcommand{\colwidth}{4.8in}
\newcommand{\zeroopen}{[0}
\newcommand{\fzclose}{f_z]^T}
\newcommand{\angvel}{\boldsymbol{\omega}}
\newcommand{\jointtorques}{\boldsymbol{\tau}}
\newcommand{\linvel}{{\bf v}}
%\newcommand{\torque}{{\bf n}}
\newcommand{\torque}{{\bf m}}
%\newcommand{\torquescalar}{n}
\newcommand{\torquescalar}{m}
\newcommand{\force}{{\bf f}}
%\newcommand{\twist}{{\bf t}}
%\newcommand{\wrench}{{\bf w}}
\newcommand{\pos}{{\bf p}}
\newcommand{\rot}{{\bf R}}
\newcommand{\partframe}{P}
\newcommand{\worldframe}{O}
\newcommand{\contactloc}{{\bf x}}
\newcommand{\contactnorm}{\hat{{\bf u}}}
%\newcommand{\config}{{\bf q}}
\newcommand{\config}{q}
\newcommand{\constraints}{{\bf f}}
\newcommand{\crossp}[1]{[#1]}
%\newcommand{\fmode}{{\tt r}}
%\newcommand{\rollmode}{\fmode}
%\newcommand{\smode}{{\tt s}}
%\newcommand{\bmode}{{\tt b}}
%\newcommand{\lmode}{{\tt s}$_\ell$}
%\newcommand{\rmode}{{\tt s}$_r$}
\newcommand{\fmode}{{\tt R}}
\newcommand{\rollmode}{\fmode}
\newcommand{\smode}{{\tt S}}
\newcommand{\bmode}{{\tt B}}
\newcommand{\lmode}{{\tt Sl}}
\newcommand{\rmode}{{\tt Sr}}
\newcommand{\wrench}{\mathcal{F}}
\newcommand{\twist}{\mathcal{V}}
\newcommand{\be}{\begin{equation}}
\newcommand{\ee}{\end{equation}}
%\newcommand{\mass}{{\textrm m}}
%\newcommand{\gravity}{{\textrm g}}
\newcommand{\mass}{\mathfrak{m}}
\newcommand{\gravity}{\mathfrak{g}}
\newcommand{\exerenumbegin}{\begin{enumerate}[itemsep=0pt,parsep=0pt,partopsep=0pt,topsep=0pt]}
\newcommand{\exerenumend}{\end{enumerate}}
%======================================================================%
% END COMMANDS FROM KEVIN %
%======================================================================%
%\input{formatting}
\usdate
\begin{comment}
\pagestyle{fancy}
\fancyhead{} % turn off default
\rfoot{\currenttime ~ \today}
\lfoot{Lynch and Park}
\lhead{\slshape \leftmark}
\end{comment}
% size so the same build works for all these cases, with character size at least the same as 10pt printed:
% 8.5x11 or A4 (8.27 x 11.69), one book page per page
% same as above, but two pages per page
% 9.7 in diagonal view tablet, which is 5.82 in x 7.76 in (3/4 ratio)
% so 4.75 in width, 7.2 in height assures 0.5'' vertical margins printed 2per on A4 paper, and 0.5'' side margins and gutter printed 2 per on 8.5x11
% 7.2 in includes text and header. if default head height is 12pt and headsep is 25pt (total 37 pt about 0.5''), that means textheight is 6.7''.
% need 1.9'' at
% but for some reason 0.6in seems to work better for centering the header+text (ignoring foo.
% maybe book class changes some spacings from defaults.
%
% VERSIONS TO MAKE:
% - tablet version (margins stripped), working hyperlinks
% - printable large font version (A4 and 8.5x11), working hyperlinks
% - printable 2 per page version (A4 and 8.5x11), hyperlinks probably don't work
% to center vertically:
\setlength{\textheight}{6.7in}
\setlength{\voffset}{0.6in}
mr2.tex
%======================================================================%
% USE TO ONLY MAKE PART OF THE BOOK %
%======================================================================%
%
%\includeonly{chapters/ch03-rbm/ch03-text}
%======================================================================%
% Title Page %
%======================================================================%
\begin{document}
\frontmatter
\begin{titlepage}
\selectfont
\begin{center}
%\renewcommand{\baselinestretch}{1.5}
\pagestyle{empty}
\LARGE{\bfseries MODERN ROBOTICS\\ \vspace*{0.2in}
\Large{MECHANICS, PLANNING, AND CONTROL}
}
\vspace{50mm}
\Large{\scshape Kevin M. Lynch and Frank C. Park} \\
\normalsize
\vspace*{0.2in}
\today
\vspace*{0.7in}
This document is the unedited preprint version of \vspace*{0.1in} \\
\large{\emph{Modern Robotics}} \\
\normalsize
\emph{Mechanics, Planning, and Control} \\
%Kevin M. Lynch and Frank C. Park \vspace*{0.1in} \\
\copyright ~Kevin M. Lynch and Frank C. Park \vspace*{0.1in} \\
\end{center}
\noindent
This preprint is being made available for personal use only and not for further distribution. The book will be published by Cambridge University Press in May 2017,
ISBN 9781107156302. Citations of the book should cite Cambridge University Press as the publisher, with a publication date of 2017. Original figures from this book may be reused provided proper citation is given. More information on the book, including software, videos, and a feedback form can be found at \url{http://modernrobotics.org}. Comments are welcome!
\end{titlepage}
\thispagestyle{empty}
\cleardoublepage
%======================================================================%
% Foreword and Preface %
%======================================================================%
%\renewcommand{\chaptermark}[1]{%
% \markboth{}{}}
%\renewcommand{\sectionmark}[1]{%
% \markright{}}
%\cleardoublepage
%\chaptermark{}
%\sectionmark{}
%\sectionmark{\href{http://lynchandpark.org}{Modern Robotics, Lynch and Park}}
%\sectionmark{some stuff}
%\pagenumbering{arabic}
\begin{comment}
\pagestyle{myheadings}
\renewcommand{\chaptermark}[1]{%
\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{%
\markright{\thesection.\ #1}}
\end{comment}
%\begin{comment}
%\newcommand{\helv}{\fontfamily{phv}\fontseries{b}\fontsize{9}{11}\selectfont}
%\newcommand{\helv}{\fontfamily{phv}\fontsize{9}{11}\selectfont}
\pagestyle{fancy}
\fancyhf{}
%\renewcommand{\headrulewidth}{0pt}
\fancyhead[LE,RO]{\small\thepage}
\fancyhead[RE]{\small\nouppercase{\rightmark}}
\fancyhead[LO]{\small\nouppercase{\leftmark}}
\fancyfoot[CO,CE]{\footnotesize \href{http://modernrobotics.org}{\copyright Lynch and Park. Nov.\ 2016 preprint of \emph{Modern Robotics}, Cambridge U.\ Press, 2017.}}
%\fancyhead[RE]{\small\scshape\nouppercase{\rightmark}}
%\fancyhead[LO]{\small\scshape\nouppercase{\leftmark}}
%\fancyhead[LE,RO]{\helv \thepage}
%\fancyhead[RE]{\helv \rightmark}
%\fancyhead[LO]{\helv \leftmark}
%\end{comment}
\setcounter{page}{1}
\tableofcontents
\cleardoublepage
\fancyhead[RE,LO]{\small Foreword}
\include{chapters/foreword/foreword}
\cleardoublepage
\fancyhead[RE,LO]{\small Preface}
\include{chapters/preface/preface-text}
\cleardoublepage
\renewcommand{\chaptermark}[1]{\markboth{\arabic{chapter}~장.\ #1}{}}
\fancyhead[RE]{\small\nouppercase{\rightmark}}
\fancyhead[LO]{\small\nouppercase{\leftmark}}
%\pagestyle{plain}
%\pagenumbering{roman}
%\setcounter{page}{2}
%\kldraft{\include{chapters/notation}}
%======================================================================%
% Table of Contents %
%======================================================================%
%\tableofcontents
%\cleardoublepage
%\addcontentsline{toc}{chapter}{List of Tables}
%\listoftables
%\cleardoublepage
%\addcontentsline{toc}{chapter}{List of Figures}
%\listoffigures
%\cleardoublepage
%\include{chapters/chapter0/ch0}
%\cleardoublepage
%======================================================================%
% Chapters %
%======================================================================%
\mainmatter
\include{chapters/ch01-preview/ch01-text}
\cleardoublepage
\include{chapters/ch02-cspace/ch02-text}
\cleardoublepage
\include{chapters/ch03-rbm/ch03-text}
\cleardoublepage
\include{chapters/ch04-kinematics/ch04-text}
\cleardoublepage
\include{chapters/ch05-velkinematics/ch05-text}
\cleardoublepage
\include{chapters/ch06-invkinematics/ch06-text}
\cleardoublepage
\include{chapters/ch07-closed/ch07-text}
\cleardoublepage
\include{chapters/ch08-dynamics/ch08-text}
\cleardoublepage
\include{chapters/ch09-trajectory/ch09-text}
\cleardoublepage
\include{chapters/ch10-planning/ch10-text}
\cleardoublepage
\include{chapters/ch11-control/ch11-text}
\cleardoublepage
\include{chapters/ch12-contact/ch12-text}
\cleardoublepage
\include{chapters/ch13-mobile/ch13-text}
\cleardoublepage
%======================================================================%
% APPENDIX %
%======================================================================%
\appendix
\cleardoublepage
\include{chapters/app1-formulas/app1-text}
\cleardoublepage
\include{chapters/app2-rotationreps/app2-text}
\cleardoublepage
\include{chapters/app3-dh/app3-text}
\cleardoublepage
\include{chapters/app4-optimization/app4-text}
\cleardoublepage\phantomsection % the \phantomsection seems to be needed to correctly hyperref
%\appendix
%\include{chapters/appendix}
%\cleardoublepage
%======================================================================%
% BIBLIOGRAPHY %
%======================================================================%
%\pagestyle{headings}
\addcontentsline{toc}{chapter}{Bibliography}
\bibliographystyle{plain}
\bibliography{robotics-frank,robotics-kevin}
\cleardoublepage\phantomsection % the \phantomsection seems to be needed to correctly hyperref
%======================================================================%
% INDEX %
%======================================================================%
%\begin{comment}
\addcontentsline{toc}{chapter}{\indexname}
\printindex
\cleardoublepage
%\end{comment}
\end{document}
It seems that I can't post images due to 10 reputations rule. Some of the errors are as below. (for mr2.tex)
The font size command \normalsize is not defined(Ln 10, Col 1)
checked for documentclass but no problem.
Environment titlepage undefined(Ln 14, Col 1)
Undefined control sequence. - many times.
error_screencapture

Latex: fail to show line breaks in formula with ```\\```

I'm using rmarkdown to knit to pdf. However, line break \\ doesn't take effect. I suspect something is wrong with my package amsmath, because running the tex file also shows the same problem. But I don't know how to fix it.
(I installed R and Rstudio with tinytex, then installed tex live 2021. I don't know whether this can be the cause.)
The code is shown below:
---
title: "test"
date: '2022-04-07'
output:
word_document: default
pdf_document:
keep_tex: yes
---
$$
a = b \\
c = d
$$
Also, when I try knit to word, there are warning messages
[WARNING] Could not convert TeX math
a = b \
c = d
, rendering as TeX:
a = b \
^
unexpected control sequence \
expecting "%", "\label", "\tag", "\nonumber" or whitespace
Building the tex file, I still cannot see the expected linebreak in the output pdf. The tex file is shown below.
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
]{article}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\#ifundefined{KOMAClassName}{% if non-KOMA class
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
\KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
pdftitle={test},
hidelinks,
pdfcreator={LaTeX via pandoc}}
\urlstyle{same} % disable monospaced font for URLs
\usepackage[margin=1in]{geometry}
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin#nat#width>\linewidth\linewidth\else\Gin#nat#width\fi}
\def\maxheight{\ifdim\Gin#nat#height>\textheight\textheight\else\Gin#nat#height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Set default figure placement to htbp
\makeatletter
\def\fps#figure{htbp}
\makeatother
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\ifLuaTeX
\usepackage{selnolig} % disable illegal ligatures
\fi
\title{test}
\author{}
\date{\vspace{-2.5em}2022-04-07}
\begin{document}
\maketitle
\[
a = b \\
c = d
\]
\end{document}
I think this should perfectly answer your question:
https://tex.stackexchange.com/questions/46189/how-do-i-add-a-line-break-in-display-math-mode
In short: \[ \] is made for one equation/one line of math. To add a line-break, you should use an environment like gather or align. The code for align would look like this in your tex-code:
\begin{align}
a &= b \\
c &= d
\end{align}
If you don't need numbering of your equations, you would use the starred version of the respective environment (gather*, align*. Like this:
\begin{align*}
a &= b \\
c &= d
\end{align*}
If the link I provided does not fit your problem, please explain why. I am happy to correct this answer.

it doesn't show the figure but just a frame and inside the file name, although the image file is uploaded in the same folder on overleaf

May the problem consist in wrong packages? The image was uploaded successfully in the folder I tried even with the function wrapfigure but the result is the same. And I tried to use the image not through the \newcommand but it cannot be read properly anyway.
\documentclass[12pt,a4paper,oneside,draft]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{imakeidx}
\makeindex[columns=3, title=Alphabetical Index, intoc]
\usepackage{graphics}
\usepackage{graphicx}
\usepackage{wrapfig}
\graphicspath{ {images/} }
\usepackage [a4paper,top=2cm,bottom=0cm,left=1cm,right=1cm]{geometry}
\textheight=5000px % Saving trees ;-)
\usepackage{url}
%%% Macros
%%% ------------------------------------------------------------
\newlength{\spacebox}
\settowidth{\spacebox}{8888888888} % Box to align text
\newcommand{\sepspace}{\vspace*{15em}} % Vertical space macro
\newcommand{\titolo}[4]{
**\begin{figure}[t]
\includegraphics[width=5cm]{logoPolimi.png}
\centering
\end{figure}**
%\vspace*{15em}
\sepspace
\centering\textbf{\huge{#1}}
\vspace{15em}
\centering\textbf{#2}
\vspace{2em}
\textbf{#3}
\vspace{2em}
\textbf{#4}}
\usepackage{caption}
%\pagenumbering{roman}
\begin{document}
\titolo{Digital Channel}{Mario Rossi}{Management Engineering}{Politecnico di Milano}
\end{document}
Thanks in advance
The figure does not appear, because you are using draft as document class option.
Unrelated to your problem, but
font commands like \huge are switches and don't take an argument. So instead of \huge{...}, you should use {\huge ...}
you don't need the graphics package if you also load graphicx
if your tex distribution is up to date, you can also skip \usepackage[utf8]{inputenc} because this is the default for some years
\documentclass[12pt,a4paper,oneside,
%draft
]{article}
%\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{imakeidx}
\makeindex[columns=3, title=Alphabetical Index, intoc]
%\usepackage{graphics}
\usepackage{graphicx}
\usepackage{wrapfig}
\graphicspath{ {images/} }
\usepackage [a4paper,top=2cm,bottom=0cm,left=1cm,right=1cm]{geometry}
\textheight=5000px % Saving trees ;-)
\usepackage{url}
%%% Macros
%%% ------------------------------------------------------------
\newlength{\spacebox}
\settowidth{\spacebox}{8888888888} % Box to align text
\newcommand{\sepspace}{\vspace*{15em}} % Vertical space macro
\newcommand{\titolo}[4]{
\begin{figure}[t]
\includegraphics[width=5cm]{example-image.png}
\centering
\end{figure}
%\vspace*{15em}
\sepspace
\centering\textbf{\huge #1}
\vspace{15em}
\centering\textbf{#2}
\vspace{2em}
\textbf{#3}
\vspace{2em}
\textbf{#4}}
\usepackage{caption}
%\pagenumbering{roman}
\begin{document}
\titolo{Digital Channel}{Mario Rossi}{Management Engineering}{Politecnico di Milano}
\end{document}

Skype symbol in cover letter made with moderncv latex

I want to include the skype symbol in the cover letter made with modern cv.
I cannot find anything that suites me. I found several cases where the symbol of skype was included after the command \begin{document}. I want to include the skype symbol before.
Here below a working example:
\documentclass[11pt,a4paper,roman]{moderncv}
\usepackage[UKenglish]{babel}
\makeatletter
\definecolor{ashgrey}{rgb}{0.7, 0.75, 0.71}
\moderncvstyle{classic}
\newcommand\subject[1]{\def\#subject{#1}} % style options are 'casual'
\moderncvcolor{green} % color options 'blue' (default), 'orange', the
\usepackage[utf8]{inputenc} % if you are not using xelatex ou lualatex, replace
\usepackage[scale=0.75]{geometry}
\name{XXXX}{XXXX}
\address{XXXX
}{XXXX}
\phone[mobile]{XXXX} % optional, remove / comment the line if not wanted
\email{XXXX} % optional, remove / comment the line if not wanted
\usepackage{ragged2e}
\usepackage{xcolor}
\makeatother
\begin{document}
\justify
\sloppy
\recipient{\mdseries To XXXX}{Phone: XXXX\\ XXXX \\ XXXX \\ XXXX}
\date{\today}
\title{Some fancy title}
\opening{ \textbf{:XXXXX}
\end{document}

The latex package "indentfirst" not working in R-markdown

I am trying to indent the first line after a section header using the indentfirst package but it is not working.
---
title: "Evaluation of Coaching Teachers by Program"
header-includes:
- \usepackage{indentfirst}
- \usepackage{booktabs}
- \usepackage{amsmath}
- \usepackage{pdflscape}
- \newcommand{\blandscape}{\begin{landscape}}
- \newcommand{\elandscape}{\end{landscape}}
author:
- "Office of Assessment and Accreditation"
- "University of South Carolina"
date: "August 2019"
output: pdf_document
---
\newpage
\blandscape
\section{\textbf{Introduction}}
The purpose of this report is to provide an overview.
\section{\textbf{Overview of all programs}}
\elandscape
Here is the latex output
\documentclass[]{article}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\else % if luatex or xelatex
\ifxetex
\usepackage{mathspec}
\else
\usepackage{fontspec}
\fi
\defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
\fi
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\usepackage[margin=1in]{geometry}
\usepackage{hyperref}
\hypersetup{unicode=true,
pdftitle={Evaluation of Coaching Teachers by Program},
pdfauthor={Office of Assessment and Accreditation; University of South Carolina},
pdfborder={0 0 0},
breaklinks=true}
\urlstyle{same} % don't use monospace font for urls
\usepackage{graphicx,grffile}
\makeatletter
\def\maxwidth{\ifdim\Gin#nat#width>\linewidth\linewidth\else\Gin#nat#width\fi}
\def\maxheight{\ifdim\Gin#nat#height>\textheight\textheight\else\Gin#nat#height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{0}
% Redefines (sub)paragraphs to behave more like sections
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
%%% Use protect on footnotes to avoid problems with footnotes in titles
\let\rmarkdownfootnote\footnote%
\def\footnote{\protect\rmarkdownfootnote}
%%% Change title format to be more compact
\usepackage{titling}
% Create subtitle command for use in maketitle
\providecommand{\subtitle}[1]{
\posttitle{
\begin{center}\large#1\end{center}
}
}
\setlength{\droptitle}{-2em}
\title{Evaluation of Coaching Teachers by Program}
\pretitle{\vspace{\droptitle}\centering\huge}
\posttitle{\par}
\author{Office of Assessment and Accreditation \\ University of South Carolina}
\preauthor{\centering\large\emph}
\postauthor{\par}
\predate{\centering\large\emph}
\postdate{\par}
\date{August 2019}
\usepackage{indentfirst}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{pdflscape}
\newcommand{\blandscape}{\begin{landscape}}
\newcommand{\elandscape}{\end{landscape}}
\begin{document}
\maketitle
\newpage
\blandscape
\section{\textbf{Introduction}}
The purpose of this report is to provide an overview of in
\section{\textbf{Overview of all programs}}
\elandscape
\end{document}
I want the first line after the section header to be indented.
The indentfirst package works, but something added \setlength{\parindent}{0pt} to your code, so the indention of the first paragraph is not visible because it is zero.
To revert this try with
\usepackage{indentfirst}
\setlength{\parindent}{20pt}
in your header includes.

Resources